[Twisted-Python] Newbie reactor.crash()/reactor.stop() question
![](https://secure.gravatar.com/avatar/0377ad34c9b8c1c06412c114e19aee4e.jpg?s=120&d=mm&r=g)
Hello, 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 running: 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. TIA, Tom
![](https://secure.gravatar.com/avatar/d6328babd9f9a98ecc905e1ccac2495e.jpg?s=120&d=mm&r=g)
On Sat, 30 Apr 2005 11:16:19 -0400, T Barket <thomas_barket@yahoo.com> wrote:
Hello,
i have read i cannot stop and restart a reactor (which is what i would like to do on the client side).
It sounds like you may have found a bug (I'll look into it) but... If you want to use the reactor interactively, look into the various incarnations of Manhole. Stopping the reactor and starting it again has lots of ugly side-effects which are hard to explain until you've had a lot of experience working with the reactor the "right" way. (If you absolutely need it, of course, it should work, and we'll fix it - but it's extremely rare that people actually need it, and pretty common that people *think* they need it.)
![](https://secure.gravatar.com/avatar/f9d8204abdba871a4463c9dc71454dc2.jpg?s=120&d=mm&r=g)
Hi, I have the exact same problem. I am using the standard unittest, not the one found in Twisted, for the moment anyway. All my tests work perfectly while using Twisted 1.3, calling reactor.crash() vs reactor.stop(). I originally had problems calling reactor. stop() with the python unittest framework, until I switched over to reactor.crash(). I then wanted to run the tests using Twisted 2.0. The python process that starts the unittest will hang after all tests are done. I can't kill the process using a CTRL-C at the command line and must use the kill -9 command. Also, I noticed that the main part of the program does execute the last print statement found at: if __name__ == "__main__": run() print( "This will print and then hang" ) The following is a bug that had similar behavior, which **may** explain the source of the issue: http://twistedmatrix.com/bugs/issue994 I am using python 2.3.4 on SUSE 9.2, and also new to Twisted... James. glyph@divmod.com wrote:
![](https://secure.gravatar.com/avatar/d6328babd9f9a98ecc905e1ccac2495e.jpg?s=120&d=mm&r=g)
On Sat, 30 Apr 2005 11:16:19 -0400, T Barket <thomas_barket@yahoo.com> wrote:
Hello,
i have read i cannot stop and restart a reactor (which is what i would like to do on the client side).
It sounds like you may have found a bug (I'll look into it) but... If you want to use the reactor interactively, look into the various incarnations of Manhole. Stopping the reactor and starting it again has lots of ugly side-effects which are hard to explain until you've had a lot of experience working with the reactor the "right" way. (If you absolutely need it, of course, it should work, and we'll fix it - but it's extremely rare that people actually need it, and pretty common that people *think* they need it.)
![](https://secure.gravatar.com/avatar/f9d8204abdba871a4463c9dc71454dc2.jpg?s=120&d=mm&r=g)
Hi, I have the exact same problem. I am using the standard unittest, not the one found in Twisted, for the moment anyway. All my tests work perfectly while using Twisted 1.3, calling reactor.crash() vs reactor.stop(). I originally had problems calling reactor. stop() with the python unittest framework, until I switched over to reactor.crash(). I then wanted to run the tests using Twisted 2.0. The python process that starts the unittest will hang after all tests are done. I can't kill the process using a CTRL-C at the command line and must use the kill -9 command. Also, I noticed that the main part of the program does execute the last print statement found at: if __name__ == "__main__": run() print( "This will print and then hang" ) The following is a bug that had similar behavior, which **may** explain the source of the issue: http://twistedmatrix.com/bugs/issue994 I am using python 2.3.4 on SUSE 9.2, and also new to Twisted... James. glyph@divmod.com wrote:
participants (3)
-
glyph@divmod.com
-
James Monteath
-
T Barket