[Python-ideas] Async API

Sam Rushing sam-pydeas at rushing.nightmare.com
Wed Oct 24 01:00:30 CEST 2012


On 10/23/12 3:05 PM, Yury Selivanov wrote:
> Sam,
>
> BTW, kudos for shrapnel!
Thanks!
>
> For basic library functions that will work.  And that's already a huge win.
> But developing a complicated library will become twice as hard, as you'll need
> to maintain two versions of API - sync & async all the way through the code.

This is really difficult, if you want to see a great example of trying
to make all parties happy, look at Pika (an AMQP implementation).

Actually this reminds me, it would be really great if there was a
standardized with_timeout()API.  It's better than adding timeout args to
all the functions.  I'm sure that systems like Twisted & gevent could
also implement it (if they don't already have it):

In shrapnel it is simply:

    coro.with_timeout (<seconds>, <fun>, *args, **kwargs)

Timeouts are caught thus:

   try:
      coro.with_timeout (...)
   except coro.TimeoutError:
      ...


> There is only one way to 'magically' make existing code both sync- & async-
> friendly--greenlets, but I think there is no chance for them (or stackless) to 
> land in cpython in the foreseeable future (although it would be awesome.)
>
> BTW, why didn't you use greenlets in shrapnel and ended up with your own
> implementation?
I think shrapnel predates greenlets... some of the core asm code for
greenlets may have come from one of shrapnel's precursors at ironport...
Unfortunately it took many years to get shrapnel open-sourced - I
remember talking with Guido about it over lunch in ~2006.

-Sam


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121023/23a35d45/attachment.pgp>


More information about the Python-ideas mailing list