On Tue, 4 Sep 2007 15:22:37 +1000, Rasjid Wilcox email@example.com wrote:
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.
The example code doesn't do anything with Events, and I'm not sure I understand what you're describing above, so I don't know if that part of your code is correct or not.
I have not really looked into the thread safety issues yet, but have been looking into reactor.callFromThread and whether it is required here.
Yes, it is. As your code is now, it calls APIs which are not threadsafe from a non-reactor thread. This isn't allowed and will definitely result in incorrect behavior sometimes.
If the entire approach is inherently broken for some reason, I'd like to know so I can look at alternatives.
I'm not sure why you're trying to do this at all, instead of just using Twisted in a single-threaded manner.