[Twisted-Python] Making non-blocking code blocking?

Paul Campbell paul at ref.nmedia.net
Fri Sep 3 16:33:29 EDT 2004


Here's the situation...

I've been writing all my code to defer correctly. Every time it gets to a point
where the call can block, I've inserted the appropriate callback function.

However, it occurred to me (for testing purposes) that it would
be nice some times to INTENTIONALLY block.

Right now, it seems like the only point where you can actually "block" is
when you reach the top level where the code is interacting with the reactor
interface.

So far, it seems like once you get the idea of writing deferred code (which
is essentially continuation passing style, right?) that it is hard to get OUT
of the mindset of writing deferreds into everything.


I'm writing a whole lot of RPC-based code right now, which means there are
LOTS of places where blocking actions can happen, so almost everything ends
up wrapped with deferreds. The alternative is to use threads, but...ugh! I
think those are even uglier.




More information about the Twisted-Python mailing list