Feature Requests item #231540, was opened at 2001-02-08 15:53
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=231540&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: Threads
>Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Dave Brueck (dbrueck)
>Assigned to: Nobody/Anonymous (nobody)
Summary: threads and profiler don't work together

Initial Comment:
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()')


----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2006-10-12 12:40

Message:
Logged In: YES 
user_id=849994

Turning into a feature request.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-08-10 05:31

Message:
Logged In: YES 
user_id=31435

Reassigned to Fred, our current profiler expert.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-02-09 23:57

Message:
Assigned to me but reduced the priority.  I'll take a look at it, but have to 
suspect it will get reclassified as a Feature Request and moved into PEP 42.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=231540&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to