[Twisted-Python] Wrapping a Perspective Broker remote object with a blocking API

Rasjid Wilcox rasjidw at gmail.com
Tue Sep 4 01:22:37 EDT 2007


Hi everyone.

I've done some reading, and it seems that there have been several
attempts by new twisted users to get Perspective Broker to function
more like Corba or DCOM.  Despite having read
http://twistedmatrix.com/pipermail/twisted-python/2007-April/thread.html#15121
on why this does not work, I have had a go and have got something that
seems to work well, at least for my test case.

Server side it is pretty standard.  Client side I run the twisted
reactor in a separate (non-main) thread, and use threading.Event()
objects placed into a 'pass through' callback to emulate blocking
until the required deferred has its result.

I have attached a simple server and client, with callback
functionality illustrated.

I have not really looked into the thread safety issues yet, but have
been looking into reactor.callFromThread and whether it is required
here.

If the entire approach is inherently broken for some reason, I'd like
to know so I can look at alternatives.

Cheers,

Rasjid.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple-client.py
Type: text/x-python
Size: 2376 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20070904/b0f57998/attachment.py 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple-server.py
Type: text/x-python
Size: 1228 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20070904/b0f57998/attachment-0001.py 


More information about the Twisted-Python mailing list