469,645 Members | 1,424 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

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
coroutines.

--
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/
Aug 3 '07 #1
0 877

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 gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.