Turning f(callback) into a generator

Diez B. Roggisch deets_noospaam at web.de
Wed Dec 3 18:26:13 EST 2003


Hi,

> This is a strange asymmetry, and I was wondering if I've overlooked a
> simple way to transform a callback into a generator, but I now tend to the
> assumption that you *need* threads: One thread with the callback puts
> names or name lists into the queue until it's full (some arbitrary limit
> that also determines the total memory needed), another thread (the
> generator) consumes names from the queue.

I also thought about that - its the only thing that allows for real lazyness
- you can wait in the callback until the generator clears a semaphore. But
if the context-changes are worth the effort is questionable. 

Diez




More information about the Python-list mailing list