[Twisted-Python] Suggestion for Deferred docs

Tommi Virtanen tv at twistedmatrix.com
Thu Feb 10 18:16:21 EST 2005


snacktime wrote:
> In the documentation on Deferred's in the howto section,  the examples
> that show a blocking operation and then a non blocking operation do
> not show what happened to the blocking code, it just conveniently
> disappears.  For someone new to async programming it might help to

The preferred approach is not to move the blocking call into a thread,
but to actually replace it with a non-blocking call.

E.g. instead of calling a getStuffFromNetwork() that blocks, call
asyncStuffGetter() that sends a request, returns a Deferred, and
when the reactor tells asyncStuffGetter() that it got a reply, it
calls deferred.callback() with the data.




More information about the Twisted-Python mailing list