Microthreads without Stackless?
fakeaddress at nowhere.org
Tue Sep 14 08:47:08 CEST 2004
> David Mertz covered this. :)
> 'Implementing "weightless threads" with Python generators.'
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
More information about the Python-list