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 kristjan.jonsson
Recipients kristjan.jonsson
Date 2010-08-16.17:17:06
SpamBayes Score 1.37556e-09
Marked as misclassified No
Message-id <1281979035.75.0.299243674716.issue9622@psf.upfronthosting.co.za>
In-reply-to
Content
issue 9609 updates _lsprof.c to be multi-stack aware.  This allows cProfile.Profile() objects to be shared by many threads and provide meaningfull results.

This update makes it more convenient to profile running, multi-threaded, applications.  By adding a set of global (cross thread) profiling hooks that override the per-thread hooks, it is possible to enable and disable profiling/tracing for the entire program.

A multithreaded python could then do something like this:
def ProfileMe(t):
  p = cProfile.Profile()
  p.enable(global=True)
  time.sleep(t)
  p.disable()
  p.print_stats()

A patch is provided, also, an updated _lsprof adding the new 'global' flag to the "enable" function.

(This paradigm is used successfully in EVE, albeit with "global" there meaning all tasklets, to do snapshot profiling of a running server.  The results are displayed on a web page served by the server backend.)
History
Date User Action Args
2010-08-16 17:17:16kristjan.jonssonsetrecipients: + kristjan.jonsson
2010-08-16 17:17:15kristjan.jonssonsetmessageid: <1281979035.75.0.299243674716.issue9622@psf.upfronthosting.co.za>
2010-08-16 17:17:13kristjan.jonssonlinkissue9622 messages
2010-08-16 17:17:11kristjan.jonssoncreate