By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,685 Members | 1,041 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,685 IT Pros & Developers. It's quick & easy.

Coroutine API

P: n/a
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*********

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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.