Microthreads without Stackless?
Bryan Olson
fakeaddress at nowhere.org
Tue Sep 14 02:47:08 EDT 2004
M.E.Farmer wrote:
> David Mertz covered this. :)
> 'Implementing "weightless threads" with Python generators.'
> http://gnosis.cx/publish/programming/charming_python_b7.html
And, to put it provocatively, David Mertz got it wrong.
As Mertz notes, generators can only transfer control to their
immediate callers. His solution of always calling them from a
scheduler is no solution at all; they still only transfer to
their immediate caller, and that caller is further restricted to
be the scheduler.
Mertz's pattern provides nothing like real co-routines or
threads, and the reliance on a scheduler has essentially nothing
to do with that. Real co-routines or threads can yield from
anywhere. Most importantly, they yield when calling for I/O.
The call-depth could be any; the import point is that whenever
one routine blocks to wait for an event, other routines can
still run.
--
--Bryan
More information about the Python-list
mailing list