[Twisted-Python] Stopping and restarting the reactor

Brian Granger bgranger at scu.edu
Wed Jun 1 18:58:01 EDT 2005


I am using twisted's client capabilities in an interactive setting.  To 
allow for interactive work, I have wrapped all my calls to connectTCP 
with a class that starts the reactor when a new set of connectTCP calls 
is made.  I stop the reactor in the clientConnectionLost method of my 
ClientFactory (when there are no more connections).

The first time I initiate a connectTCP call in my wrapper class 
everything works as expected:  the reactor is started, twisted does its 
stuff, and the ClientFactory stops the reactor (giving me back 
interactive controll).  BUT, if I the initiate another connectTCP call, 
the reactor starts, but then I get a User Timeout error showing up.  
That is, the second time, no connection is made.  My ClientFactory 
again stops the reactor (this time in clientConnectionFailed), but then 
python hangs.

My question:  is the reactor designed to be started/stopped/restarted 
in a single session?  If so, are there any considerations that I am 
missing?  Why doesn't the connection get made the second time?

Thanks in advance


The first time

Brian E. Granger
Assistant Professor of Physics
Santa Clara University

bgranger at scu.edu
Phone: 408-551-1891
Fax: 408-554-6965

More information about the Twisted-Python mailing list