473,573 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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*********@goo glegroups.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(a rg), 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 970

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Emmanuel | last post by:
Hi, I run across this problem, and couldn't find any solution (python 2.2.2) : Code : =========== from __future__ import generators >>> class titi:
by: Carlos Ribeiro | last post by:
As a side track of my latest investigations, I began to rely heavily on generators for some stuff where I would previsouly use a more conventional approach. Whenever I need to process a list, I'm tending towards the use of generators. One good example is if I want to print a report, or to work over a list with complex processing for each...
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
by: Kovan Akrei | last post by:
Hi, I would like to know how to reuse an object of a thread (if it is possible) in Csharp? I have the following program: using System; using System.Threading; using System.Collections; public class A {
by: Jiri Kripac | last post by:
Languages such as Simula 67 contain a general concept of coroutines that allow the execution of a method to be suspended without rolling back the stack and then later resumed at the same place as it has been suspended. The C# iterators seem to be a special case of this general suspend/resume concept. The "yield" statement suspends the...
by: Kovan Akrei | last post by:
Hi, I wonder if it is possible to rewrite a method that uses monitors and lock keyword as shown below to use waithandles instead. My method makes sure that only one thread in my system is running at all time. It is gives control to a specific thread given by the paramter. I want to find out if it is possible to rewrite this method to use...
by: ballpointpenthief | last post by:
How good is the C language for implementing maps, filters and accumulators? SCHEME programmers would be able to pass procedures as arguments quite easily, whereas C programmers would - I guess - have use variadic function pointers which is frankly disgusting, and I'm not even sure I want to sit down and hack at the language in that way. ...
by: Marshall T. Vandegrift | last post by:
Hi, I'm trying to write a decorator which allows one to produce simple coroutines by just writing a function as a generator expression which re-receives it's arguments as a tuple from each yield. For example: @coroutine def nextn(n=1): values = for i in itertools.count():
by: Matthew Wilson | last post by:
I'm working on two coroutines -- one iterates through a huge stream, and emits chunks in pieces. The other routine takes each chunk, then scores it as good or bad and passes that score back to the original routine, so it can make a copy of the stream with the score appended on. I have the code working, but it just looks really ugly. Here's...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.