Ray.Allen <[email protected]> added the comment:
I don't think this problem still exists now. In the current implementation,
there is no "sys_tracefunc" and "sys_profilefunc" in PyThreadState, but
"c_profilefunc", "c_profileobj", "c_tracefunc", "c_traceobj" instead. When
creating a new thread, the "c_profilefunc" and "c_tracefunc" are inherited from
main thread, and the profile function is thread specific, it only collect
profile statistic of the executing functions in its own thread, that is, each
thread can profile its own executing.
I'd change the example as follows:
def child():
def yo():
for j in range(5):
print(j)
profile.runctx('yo()', globals(), locals())
def go():
threading.Thread(target=child).start()
time.sleep(1)
profile.runctx('go()', globals(), locals())
This will output two profile statistics, one is for main thread, another is for
child thread: child(). So if you want to profile a child thread, just call
profile.run() in child thread.
So I don't think this is a problem.
----------
nosy: +ysj.ray
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue231540>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com