Turning f(callback) into a generator

Diez B. Roggisch deets_noospaam at web.de
Thu Dec 4 00:26:13 CET 2003


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


More information about the Python-list mailing list