How to determine if threads are active in an application?

python at python at
Fri Feb 26 23:10:30 CET 2010

Is there technique to determine if threads are active in a Python

The only technique I can think of is to check sys.modules for
thread and threading. But this will only show whether these
modules were imported - not whether there are actually background
threads running.

Motivation: We were debugging a customer's python application and
they had a module that was unknowningly (to both us and them)
creating threads in certain situations. This made our debugging
process more complicated because there were side effects
happening at unexpected times that we couldn't explain. The
module in question was supplied to us as a compiled module that
was considered fully tested by the customer. To prevent this
confusion in the future, we're looking for a way that we can
detect threads are active while we're debugging without having to
manually step through every line of code in every module to check
for unexpected thread creation.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list