[Python-ideas] [Python-Dev] Python needs a standard asynchronous return object (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Sun Sep 12 18:17:51 CEST 2010


On Sun, 12 Sep 2010 08:49:56 -0700 Guido van Rossum <guido at python.org> wrote:

Sure, but the tricky thing is to make it pluggable so that PEP 3148 and Twisted and other frameworks can use it all together, and a single call will accept a mixture of Futures.

Having a common abstraction (Future or Deferred) allows for scheduling-agnostic libraries which consume and/or produce these abstractions (*). I'm not sure it is desireable to mix scheduling models in a single process (let alone a single thread), though.

(*) Of course, the abstraction is somehow leaky since being called from different threads, depending on the scheduling model, could have adverse consequences

ISTM that the main difference is that adddonecallback() isn't meant for callbacks that return a value. So then the exceptions that might be raised are kind of "out of band".

It implies that it's mostly useful for simple callbacks (which would e.g. print out a success report, or set an Event to wake up another thread). The Twisted model allows the major part of processing to occur in the callbacks themselves, in which case proper error handling and propagation is mandatory.

Regards

Antoine.



More information about the Python-ideas mailing list