[Twisted-Python] calling reactor.run() twice in PB app

Eric Smith eric+twisted at trueblade.com
Wed Feb 15 13:58:48 EST 2006

I have a non-authenticating, single-threaded, Perspective Broker
application.  I'm running Python 2.3, Twisted 2.0.1 on Fedora Core 2.

I want to run the reactor multiple times, serially.  Essentially I have 
an existing program, and I want to make some PB calls to get some data. 
  The existing program isn't twisted-aware, nor do I want it to be.  I 
just want them to do what's needed to contact a PB server, get some 
data, and disconnect.

To demonstrate the problem,  I took the PB code from chapter 5 of the 
O'Reilly twisted book (pb_client.py and pb_server.py).  In pb_client.py, 
I duplicated the last 3 lines so now it says:

t = PbTester()

t = PbTester()

The code runs twice, but the second call to reactor.run() never returns 
because the getRootObject() deferred never gets called.  If I wait long 
enough, I get a timeout.

While the client is hung, I can connect to the same server with another 
client, and it works normally (at least until the second reactor.run() 
call).  The server seems to be perfectly fine, and keeps responding. 
CPU usage on the box is normal.

Is there something I need to do to run the reactor twice?  I've tried 
changing to Unix domain sockets, but other than not getting a timeout, I 
get the same behavior.

Any hints or debugging tips would be appreciated.



More information about the Twisted-Python mailing list