473,320 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Current execution frame of another thread?

I would like to try a sampling approach to profiling. My thought is to have
a profiling thread that samples the execution frame of all the other
started threads. I don't see any path from the threads returned by
threading.enumerate() to their current frames. Am I missing something?

Thx,

Skip

Nov 22 '05 #1
4 2252
sk**@pobox.com wrote:
I would like to try a sampling approach to profiling. My thought is to have
a profiling thread that samples the execution frame of all the other
started threads. I don't see any path from the threads returned by
threading.enumerate() to their current frames. Am I missing something?


I doubt that works. As python uses the OS underlying threading model, it
doesnn't know about the internal management structures - and even it
knew, these had to be carefully designed for that exact purposes of
yours, as the stack frame can only be safely inspected by the thread
_running_ in it.

An external thread could be interrupted at all times while traversing
other threads management structures, and then find a corrupted memory
location when it is re-scheduled.

Maybe one could write a threading model that allwos for hooks in the
scheduler (which has all the time in the world for such stuff) - but I'm
not aware that that's possible under e.g. pthreads, so there is unlikely
a python-way to do so.

Regards,

Diez
Nov 22 '05 #2
sk**@pobox.com wrote:
I would like to try a sampling approach to profiling. My thought is to have
a profiling thread that samples the execution frame of all the other
started threads. I don't see any path from the threads returned by
threading.enumerate() to their current frames. Am I missing something?


I doubt that works. As python uses the OS underlying threading model, it
doesnn't know about the internal management structures - and even it
knew, these had to be carefully designed for that exact purposes of
yours, as the stack frame can only be safely inspected by the thread
_running_ in it.

An external thread could be interrupted at all times while traversing
other threads management structures, and then find a corrupted memory
location when it is re-scheduled.

Maybe one could write a threading model that allwos for hooks in the
scheduler (which has all the time in the world for such stuff) - but I'm
not aware that that's possible under e.g. pthreads, so there is unlikely
a python-way to do so.

Regards,

Diez
Nov 22 '05 #3
sk**@pobox.com wrote:
I would like to try a sampling approach to profiling. My thought is to have
a profiling thread that samples the execution frame of all the other
started threads. I don't see any path from the threads returned by
threading.enumerate() to their current frames. Am I missing something?

Just another thought: Maybe stackless python can be of use here - as it
epxlicits the stack frame, you might be able to inspect it. But I
_think_ basically the same limitations apply as in my other post - you'd
need to be able to stop a thread, scan its frame, and reschedule it.

Diez
Nov 22 '05 #4
sk**@pobox.com wrote:
I would like to try a sampling approach to profiling. My thought is to have
a profiling thread that samples the execution frame of all the other
started threads. I don't see any path from the threads returned by
threading.enumerate() to their current frames. Am I missing something?

Just another thought: Maybe stackless python can be of use here - as it
epxlicits the stack frame, you might be able to inspect it. But I
_think_ basically the same limitations apply as in my other post - you'd
need to be able to stop a thread, scan its frame, and reschedule it.

Diez
Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Don | last post by:
Given a page with a "header" and "main" frame, is there some way from the "header" frame to initiate re-execution of the JavaScrip/HTML code in the "main" frame? I don't want to have to reload...
3
by: Peter Rilling | last post by:
How do I put to sleep a thread other than the current one? I want to put another thread to sleep to the specified number of milliseconds but the Sleep method seems to only work for the current...
4
by: Vlad | last post by:
I have implemented an asyncrhonous execution of a method using the delegate's BeginInvoke() I am trying to spin multiple worker threads in a thread pool. Here is the code: TestProcess process =...
1
by: Stropher | last post by:
Hi! I have a db-query which takes too long to complete. In this process, it will not be bad notifying the user that something is being done so as to exercise some patience. How can I realise...
10
by: greenb | last post by:
Our asp.net web app uses a .NET component (DLL) in the bin directory to call several stored procedures back to back to perform updates. They don't return any data. Sometimes the total execution...
0
by: skip | last post by:
I would like to try a sampling approach to profiling. My thought is to have a profiling thread that samples the execution frame of all the other started threads. I don't see any path from the...
1
by: Selva Chinnasamy | last post by:
I have read large amount of data from Ms-Access database to build BinaryArray. I like to know how can I stop the current execution after it is statrted. Functions build the Binary array is not...
42
by: smerf | last post by:
Using javascript, is there a way to trap an external page inside a frame? I've seen scripts to break out of frames, but nothing to keep a page trapped in a frame.
10
by: Michael B. Trausch | last post by:
Alright, I seem to be at a loss for what I am looking for, and I am not even really all that sure if it is possible or not. I found the 'pdb' debugger, but I was wondering if there was something...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.