This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dbrueck
Recipients
Date 2001-02-08.15:53:43
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
When a new thread is created, it doesn't inherit from the parent thread the trace and profile functions (sys_tracefunc and sys_profilefunc in PyThreadState), so multithreaded programs can't easily be profiled. 

This may be by design for safety/complexity sake, but the profiler module should still find some way to function correctly. A temporary (and performance-killing) workaround is to modify the standard profiler to hook into threads to start a new profiler for each new thread, and then merge the stats from a child thread into the parent's when the child thread ends.

Here is sample code that exhibits the problem. Stats are printed only for the main thread because the child thread has no profiling function and therefore collects no stats:

import threading, profile, time

def yo():
    for j in range(5):
        print j,

def go():
    threading.Thread(target=yo).start()
    time.sleep(1)

profile.run('go()')
History
Date User Action Args
2007-08-23 16:00:00adminlinkissue231540 messages
2007-08-23 16:00:00admincreate