[Twisted-Python] Perspective Broker with blocking, non-thread-safe C api?

Phil Mayers p.mayers at imperial.ac.uk
Wed Jul 11 05:43:20 EDT 2007

On Wed, 2007-07-11 at 00:34 +0000, s. w. wrote:
> I'd like to use Perspective Broker to serve a set of objects remotely.  
> However, these objects wrap a non-thread-safe, blocking C api.  I'm new to 
> Twisted, but I believe I understand correctly that the blocking C api needs 
> to be accessed via threads in Twisted.
> Given this, the only way I can think to use Perspective Broker would be to 
> use a special PBServerFactory/Protocol that limited the server to one 
> connected client.  For the use I would be putting the server to, this is 
> maybe not as horrible as it sounds, but it is probably as ugly as it sounds.
> I'm hoping there's something in PB that I haven't come across that can solve 
> this problem in a more elegant way.  Any help or pointers would be greatly 
> appreciated.

It's not specific to PB - this applied to all of Twisted, and all of
Twisted has the same solution.

See "deferToThread" for examples of ways to call blocking APIs inside a
thread, and when the call returns the deferred will fire.

> Thanks,
> Steve
> _________________________________________________________________
> http://newlivehotmail.com
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list