[Twisted-Python] Receiving a root from a pb client

Brian Warner warner at lothar.com
Tue Dec 27 13:15:42 EST 2005

william.lewis at uk.bnpparibas.com writes:

> I am using pb to communicate in a client-server configuration. My client
> inherits from PBClientFactory. My server has a remote_take_root() method
> by which the client can connect to the server and pass in its root, thus
> allowing two-way communication. Is there anyway for the server to
> re-establish the connection (should it go down) in this setup, or is
> this the sole responsibility of the client?

The other posters in this thread have it exactly right. The RemoteReference
that is received by your remote_take_root() method does not carry enough
information to allow anyone else (including your server) to initiate a new
connection to the Broker which hosts it. In this configuration, the "client"
side (specifically the side which initiates the PB connection with a
PBClientFactory) must be responsible for any sort of reconnection.

Incidentally, in newpb this won't necessarily be the case. Both ends can
listen on a TCP socket, and the RemoteReference that you receive may contain
enough information to connect to its source. It is still a good idea to make
exactly one side be responsible for things like reconnection, though, because
otherwise you get a bunch of ugly race conditions as both sides attempt to
connect at the same time. (newpb handles this for you, so you'll only get a
single connection between the two Tubs, but it's still ugly). Also, the
application level should be aware of the reconnection events, otherwise it
becomes more difficult to be sure about which methods have been successfully
invoked and which have not.


More information about the Twisted-Python mailing list