472,145 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Coroutine API

I was talking to some other people, who all were working on different
schedulers and such for coroutines. We decided to work out a common
API to give coroutines, and common rules to passing data between them,
etc. I am wondering now if there is already work on this, or some
schedulers I'm not aware of that have any deployment and a good,
simple design.

We also setup a group to discuss this and iron out our details and
some common coroutines. py*********@googlegroups.com

We came up with this basic rule set:
1) A coroutine can be any iterable
2) A coroutine yielding None is suspending to allow others to run
3) A coroutine yielding something else is yielding another coroutine
and needs to stay suspended until that coroutine has a value to pass
to the send() method of the coroutine.
4) In the above case, if the yielded coroutine raises an exception, it
is passed to the waiting coroutine's throw() method.
5) A coroutine raising StopIteration(arg), where arg is its final
result, expects arg to be passed to the send() method of any coroutine
which is waiting for its completion.

The idea is that we don't rely on defining any new types or functions
and we keep it extremely simple. I'd like to consider it WSGI for

Read my blog! I depend on your acceptance of my opinion! I am interesting!
Aug 3 '07 #1
0 923

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Emmanuel | last post: by
149 posts views Thread by Christopher Benson-Manica | last post: by
34 posts views Thread by Kovan Akrei | last post: by
14 posts views Thread by Jiri Kripac | last post: by
reply views Thread by Kovan Akrei | last post: by
10 posts views Thread by ballpointpenthief | last post: by
6 posts views Thread by Marshall T. Vandegrift | last post: by
1 post views Thread by Matthew Wilson | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.