[Twisted-Python] Newbie reactor.crash()/reactor.stop() question

T Barket thomas_barket at yahoo.com
Sat Apr 30 11:16:19 EDT 2005


I have set up a server and client with perspective broker and can
successfully move data back and forth between them.  however, i want to use
the client interactively at the python prompt.  ie, i want to create a
client object, make a request of the server and get the data returned to me.
then i want to do some work with the data interactively at the python
command prompt, until i need new data.  then i want to use the client again
to make another request of the server, etc.

i have read i cannot stop and restart a reactor (which is what i would like
to do on the client side).  then i found out about reactor.crash().  that
seems to work fine, which i think allow me to put the reactor on hold so i
can get back to the command prompt and do some work until i need to make
another request to the server.  At least I can get it to work as expected.
however, i now dont know how to call "reactor.stop()" before I exit python.
once the client finishes, it sets a "reactor.crash()".  now when I try to
call reactor.stop(), i get the following error that the reactor isnt

    raise RuntimeError, "can't stop reactor that isn't running"
RuntimeError: can't stop reactor that isn't running

so now i cant stop the reactor using reactor.stop().  and furthermore, when
i try to exit the python command prompt (having run reactor.crash() but not
reactor.stop()), the python command prompt hangs instead of exiting normally
and I have to kill its process.  is there any way to exit python normally
when the reactor has been put into a reactor.crash()?

im using twisted 2.0 and python 2.4.1 on windows xp sp2.



More information about the Twisted-Python mailing list