Turning f(callback) into a generator

Peter Otten __peter__ at web.de
Fri Dec 5 12:49:08 EST 2003


Alan Kennedy wrote:

> Peter, you may find the following message from Stephen Taschuk
> interesting. It is an approach to the producer/consumer problem,
> through the use of coroutines. Only the bottom half of his post will
> be of interest. The top half relates to another question I was asking
> him at the time.
> 
>
http://groups.google.com/groups?selm=mailman.1054317657.5272.python-list%40python.org&rnum=8
> 
> I think it might be something closer to what you're looking for.

Very interesting indeed, thanks. 
At first glance I think it will not solve the particular problem, as all
participants (read/write/consumer/producer) are generators, which is not an
option here, as I want to "tunnel" data from a callback inside code that
assumes it is calling a normal function.
On the other hand, although I always thought of the callback as the
producer, there might be a way to put the *dispatcher* into the callback -
and then bingo.
So I'll definitely have a closer look at this promising approach.

Peter




More information about the Python-list mailing list