[issue10220] Make generator state easier to introspect

2010-11-29 Thread Nick Coghlan
Nick Coghlan added the comment: Switched to strings in r86879. -- status: open -> closed ___ Python tracker ___ ___ Python-bugs-list

[issue10220] Make generator state easier to introspect

2010-11-22 Thread Guido van Rossum
Guido van Rossum added the comment: Yes please. On Mon, Nov 22, 2010 at 7:44 AM, Nick Coghlan wrote: > > Nick Coghlan added the comment: > > Temporarily reopening to remind me to switch from using integer constants to > strings (which are much friendlier for debugging purposes). > >

[issue10220] Make generator state easier to introspect

2010-11-22 Thread Nick Coghlan
Nick Coghlan added the comment: Temporarily reopening to remind me to switch from using integer constants to strings (which are much friendlier for debugging purposes). -- status: closed -> open ___ Python tracker

[issue10220] Make generator state easier to introspect

2010-11-20 Thread Nick Coghlan
Nick Coghlan added the comment: Committed in r86633. I added the missing docs changes, and tweaked the tests a little bit: - added a helper method to retrieve the generator state in the test case - this allowed test_running to be simplified a bit - added an explicit test for the CREATED->CLOSED

[issue10220] Make generator state easier to introspect

2010-11-20 Thread Nick Coghlan
Nick Coghlan added the comment: I'll actually go with version 1 of the patch as far as the variable initialisation goes. Yes, it is fractionally slower, but you get a maintenance gain from the fact that the enum values are guaranteed to be orthogonal, and this is clearly obvious to the reader

[issue10220] Make generator state easier to introspect

2010-11-20 Thread Éric Araujo
Éric Araujo added the comment: Nice. Now you can sit back, relax and wait for Nick to commit the patch or make further comments. -- stage: needs patch -> patch review ___ Python tracker _

[issue10220] Make generator state easier to introspect

2010-11-20 Thread Rodolpho Eckhardt
Rodolpho Eckhardt added the comment: Done, thank you! Second version attached. -- Added file: http://bugs.python.org/file19712/getgeneratorstate_v2.patch ___ Python tracker ___

[issue10220] Make generator state easier to introspect

2010-11-20 Thread Rodrigo Bernardo Pimentel
Changes by Rodrigo Bernardo Pimentel : -- nosy: +rbp ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mai

[issue10220] Make generator state easier to introspect

2010-11-20 Thread Éric Araujo
Éric Araujo added the comment: Looks good, modulo two nitpicks: 1) Using literals for constants would avoid a lookup and call of range. 2) Please remove four leading spaces in your docstring. -- nosy: +eric.araujo ___ Python tracker

[issue10220] Make generator state easier to introspect

2010-11-20 Thread Rodolpho Eckhardt
Rodolpho Eckhardt added the comment: This patch adds the getgeneratorstate function and related tests. -- keywords: +patch nosy: +Rodolpho.Eckhardt Added file: http://bugs.python.org/file19705/getgeneratorstate.patch ___ Python tracker

[issue10220] Make generator state easier to introspect

2010-10-30 Thread Zbyszek Szmek
Changes by Zbyszek Szmek : -- nosy: +zbysz ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue10220] Make generator state easier to introspect

2010-10-28 Thread Nick Coghlan
Changes by Nick Coghlan : -- assignee: -> ncoghlan ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

[issue10220] Make generator state easier to introspect

2010-10-28 Thread Nick Coghlan
Nick Coghlan 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_

[issue10220] Make generator state easier to introspect

2010-10-28 Thread Guido van Rossum
Guido van Rossum added the comment: I take it back. The 4-value state looks better. My initial hesitance was that if you ever see GEN_RUNNING you are probably already in trouble, since you can't call send, next, throw or even close on a running generator (they all throw ValueError), so why are

[issue10220] Make generator state easier to introspect

2010-10-28 Thread Nick Coghlan
Nick Coghlan added the comment: So something like: GEN_CREATED, GEN_ACTIVE, GEN_CLOSED = range(3) def getgeneratorstate(g): """Get current state of a generator-iterator. Possible states are: GEN_CREATED: Created, waiting to start execution GEN_ACTIVE: Currently being executed (o

[issue10220] Make generator state easier to introspect

2010-10-28 Thread Guido van Rossum
Guido van Rossum added the comment: I could imagine separating the state into two parts: - a three-valued enum distinguishing created, active, or exhausted - a bool (only relevant in the active state) whether it is currently running or suspended The latter is just g.gi_running so we don't ne

[issue10220] Make generator state easier to introspect

2010-10-28 Thread Nick Coghlan
Nick Coghlan added the comment: On Thu, Oct 28, 2010 at 10:55 PM, Antoine Pitrou wrote: > > Antoine Pitrou added the comment: > > Is it CPython-specific? The states are not CPython-specific (they're logical states of the underlying generator), but I don't know if other implementations expose

[issue10220] Make generator state easier to introspect

2010-10-28 Thread Antoine Pitrou
Antoine Pitrou added the comment: Is it CPython-specific? Does "currently executing" also include "currently closing"? -- nosy: +pitrou ___ Python tracker ___ __

[issue10220] Make generator state easier to introspect

2010-10-28 Thread Nick Coghlan
New submission from Nick Coghlan : Generators can be in four different states that may be relevant to framework code making use of them (especially as coroutines). This state is all currently available from Python code, but is rather obscure and could be made readable. The four states are: Cr