[Twisted-Python] Hanging test cases (Was: Evangelism notes...)

Grant Baillie grant at osafoundation.org
Thu May 5 13:05:23 MDT 2005


On May 5, 2005, at 11:49 AM, Grant Baillie wrote:

> So far as I can tell, the python threading module has an atexit  
> handler that's hanging. Also, if I replace the deferToThread() with  
> a twisted.web.client.getPage(), I still get the same hang.

Er, I'd already replaced the deferToThread() in an earlier version of  
that file with twisted.web.client.getPage(), for anyone following  
along at home.

I also found a hackaround, which is to insert the following before  
the call to getPage:

#---------------
import threading
# threading seems to install an atexit() handler that
# can wedge if you've run the reactor. So, we import it
# first....

import atexit

def runAndStop():
     if not reactor.running:
         reactor.callLater(0, reactor.stop)
         reactor.run()

# ... then our handler will be called before threading's.
atexit.register(runAndStop)
#---------------

I'm not sure if this is a problem in python, in twisted's use of  
threading, or in trial.deferredResult, though.

--Grant

Grant Baillie
Open Source Applications Foundation







More information about the Twisted-Python mailing list