This is an addition of the post Producer/Consumer in Python I wrote earlier.
It’s just the same example rewritten with py.magic.greenlet.
Greenlets, tasklets, micro-threads, coroutines are basically the same thing: suspending and resuming a function in multiple points is the core feature we need.
In the previous example we did it with plain old generators, now we try to use the greenlets in py library.
I won’t comment the code line by line because nothing really changes except the API of the library involved. In our case the key feature is greenlet.switch() which switches from one greenlet to another. That’s really it.
You can find the full example here: prodcons-greenlet.py

