[Twisted-Python] Hanging test cases (Was: Evangelism notes...)
Bob Ippolito
bob at redivi.com
Thu May 5 15:26:23 EDT 2005
On May 5, 2005, at 3:05 PM, Grant Baillie wrote:
>
> 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.
Almost definitely a combination of 2 and 3, with 3 being the one
really at fault. Trial is horribly, horribly broken by design and
it's really just an accident that it works at all. The expectations
a lot of the tests have about the reactor are also broken, but that's
mostly just a consequence of trial sucking.
-bob
More information about the Twisted-Python
mailing list