[Twisted-Python] 9.0.0 question

Mikhail Terekhov termim at gmail.com
Fri Jan 22 17:42:19 EST 2010

On Fri, Jan 22, 2010 at 4:40 PM,  <exarkun at twistedmatrix.com> wrote:
> On 21 Jan, 03:30 pm, termim at gmail.com wrote:
>> [snip]
>> 2. Why reactor.stop() hangs if it is called before reactor.run()?
> It doesn't.  It raises an exception.  The reason the example hangs is that

Care to elaborate? Who hangs then and why python exits and I see this
exception only after I hit Cntl-C?

Actually I noticed this problem in my old wxPython/Twisted application.
Before upgrade everything was sweet and shiny but when I upgraded
Twisted to 9.0 my application suddenly started to hang on exit. BTW
I use wxreactor and install it exactly as in doc/core/examples/wxdemo.py

It is interesting that doc/core/examples/wxacceptance.py has no such a problem,
but doc/core/examples/wxdemo.py has! If I start it, wait till it
prints to stdout
"two seconds passed" and then try to quit it either by File->Exit or by clicking
on the WM close button it does not respond, even if I hit Cntrl-C in the
terminal from where I run it, but if after Cntrl-C I go to the
File->Exit it quits
after printing "Received SIGINT, shutting down."

terekhov at _:~/Twisted-9.0.0/doc/core/examples >python wxdemo.py
2010-01-22 17:16:03-0500 [-] Log opened.
2010-01-22 17:16:05-0500 [-] two seconds passed
2010-01-22 17:21:03-0500 [-] Received SIGINT, shutting down.
terekhov at _:~/Twisted-9.0.0/doc/core/examples >

Another clue is that if I'm fast enough and can click on the close button
_before_ it prints "two seconds passed", then everything is fine and it
quits without problem:

terekhov at _:~/Twisted-9.0.0/doc/core/examples >python wxdemo.py
2010-01-22 17:23:59-0500 [-] Log opened.
2010-01-22 17:24:01-0500 [-] two seconds passed
terekhov at _:~/Twisted-9.0.0/doc/core/examples >

On the same note may be doc/core/examples/wxacceptance.py has no
such a problem because it uses reactor.callLater(0.1,helloWorld)?

I used gethostbyname.py as an example only because it is much smaller
and the behavior is very similar. May be it is something different.

> since reactor.stop() was called before reactor.run(), it's not called
> *after* reactor.run().  So the reactor never stops.
That is nice :)

Mikhail Terekhov

More information about the Twisted-Python mailing list