Nick Coghlan <ncogh...@gmail.com> added the comment:

Indeed, the minimal lifecycles are:

GEN_CREATED->GEN_CLOSED (exception thrown in before the generator was even 
started)
GEN_CREATED->GEN_RUNNING->GEN_CLOSED (initial next() with internal logic that 
skips all yields)
GEN_CREATED->GEN_RUNNING->GEN_SUSPENDED->GEN_RUNNING->GEN_CLOSED (initial 
next() with a throw, next or send to close it)

Other cases following the same basic pattern as the last one, they just bounce 
back and forth between suspended and running more times.

It occurred to me that threads really use the same state machine, it's just 
that almost nobody writes their own Python thread schedulers, so only _thread 
and threading care about the suspended/running distinction. There are quite a 
few different generator schedulers though, so the distinctions matters to more 
3rd party code than it does for threads.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10220>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to