[Twisted-Python] PB release connection
Uwe C. Schroeder
uwe at oss4u.com
Tue Sep 28 20:50:59 EDT 2004
-----BEGIN PGP SIGNED MESSAGE-----
Ok, I have to answer this one myself (after 2 days....)
It's not easy to release a connection from the server side since the avatar
object retains no reference to the underlying transport.
What I did now is subclass the pb.Avatar class and add the line
to the perspectiveMessageReceived method.
Not a nice solution, but it works. After the first message that came thru the
socket (in my case) you can call
in your usual "perspective" (which needs to implement the modified Avatar
If you're using a pb.Root object you can overwrite the rootObject method to
retain a reference to the broker instance (meaning subclass the flavor.Root
class with a modified rootObject method and use this new root class as
argument to the ServerFactory)
Hope that saves someone a day of digging in the sources.
On Saturday 25 September 2004 01:31 pm, Uwe C. Schroeder wrote:
> after browsing the docs,api and mailinglist I couldn't find what I'm
> looking for. I'm using a simple pb server with a pb.Root object (don't need
> authentication). What I want to do is release the connection from the
> server-side. Server code looks like:
> class MyPerspective(pb.Root):
> so far so good. MyPerspective receives all the remote_ calls. Now I'd like
> to be able to get rid of a specific client (which holds a remote-reference
> to MyPerspective). With the old pb api there was a way to do call
> perspective.broker.transport.loseConnection(), which I was using on the
> client side to end the connection.
> I can't see anything like this with the new API that would allow me to
> initiate the "kick off" from the server side.
> Can this be done? What would be the propper way to release a connection
> from the server side?
> Thanks for any enlightenment.
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the Twisted-Python