<!--/*SC*/DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"/*EC*/-->
<html><head><title></title><style type="text/css"><!--body{padding:1ex;margin:0px;font-family:sans-serif;font-size:small;}a[href]{color:-moz-hyperlinktext !important;text-decoration:-moz-anchor-decoration;}blockquote{margin:0;border-left:2px solid #144fae;padding-left:1em;}blockquote blockquote{border-color:#006312;}blockquote blockquote blockquote{border-color:#540000;}--></style></head><body><div style="font-family: Arial; font-size: medium;" dir="ltr"><div>Is there technique to determine if threads are active in a Python application?</div>
<div> </div>
<div>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.</div>
<div> </div>
<div>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.</div>
<div> </div>
<div>Thanks,</div>
<div>Malcolm</div></div></body></html>