[Twisted-Python] Deferred documentation rewrite
andrewfr_ice at yahoo.com
Tue Aug 4 13:54:17 EDT 2009
Date: Mon, 03 Aug 2009 18:00:07 -0400
From: "Edward Z. Yang" <ezyang at MIT.EDU>
Subject: Re: [Twisted-Python] Deferred documentation rewrite
To: Twisted general discussion <twisted-python at twistedmatrix.com>
Message-ID: <1249336297-sup-7263 at javelin>
Content-Type: text/plain; charset=UTF-8
> - Asynchronous interaction to synchronous interaction
> - Delocalized execution (the parser example)
> - High level functions in Python review
I don't know if this is an aid but here goes: When I was preparing my
Pycon 2008 talk, amongst the many papers I read, was the Doug
Schmitt's concurrency design pattern papers including the original
Reactor Pattern paper. I also read the Microsoft "Cooperative Task Management without Manual Stack Management Event-driven Programming is Not the Opposite of Threaded Programming" paper. In the light of those papers,
this is the way I see things:
1) Reactors provide a portable form of non-preemptive multitasking. By
implication, reactors are schedulers.
2) If you buy Reactor as scheduler, then Deferreds can be viewed as representing a thread (or chain) of execution, each callback analogous to a continuation - the next address to resume execution when a result is ready.
3) One of the main differences between asychronous and synchronous processing becomes who is responsible for setting up shared state between
the links in the execution chain.
>Quite frankly, I'm stumped on "defining synchronous and asynchronous."
Simple definition: In a synchronous call, the caller blocks until a result is ready. Upon return the next statement is executed (barring something like an exception). In an asynchronous call, the caller does not wait for a result and continues.
> I just don't know what direction people are coming from.
I would suggest most people are trying to solve simple problems and want the least surprise. Unfortunately asynchronous programming has lots of
surprises. In case of terminology, try looking up how terms
like 'asynchronous' or 'synchronous' as used in a few of the more
popular network programming books.
More information about the Twisted-Python