[Python-Dev] Pythonic concurrency - cooperative MT

Martin Blais blais at furius.ca
Sun Oct 2 23:49:51 CEST 2005

On 10/1/05, Antoine <solipsis at pitrou.net> wrote:
> > like this with their "deferred objects", no?  I figure they would
> > need to do something like this too.  I will have to check.)
> A Deferred object is just the abstraction of a callback - or, rather, two
> callbacks: one for success and one for failure. Twisted is architected
> around an event loop, which calls your code back when a registered event
> happens (for example when an operation is finished, or when some data
> arrives on the wire). Compared to generators, it is a different way of
> expressing cooperative multi-threading.

So, the question is, in Twisted, if I want to defer on an operation
that is going to block, say I'm making a call to run a database query
that I'm expecting will take much time, and want to yield ("defer")
for other events to be processed while the query is executed, how do I
do that?  As far as I remember the Twisted docs I read a long time ago
did not provide a solution for that.

More information about the Python-Dev mailing list