diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2010-11-21 03:44:04 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2010-11-21 03:44:04 (GMT) |
commit | e0f04659cd717a031b42dcfd43ca07824b24f9b2 (patch) | |
tree | 63fbd71f11a93bb398b5d1f6c2d91b116bc7d78e /Doc/library | |
parent | d3309df40b5335ebf225a359e5cb3b324801e221 (diff) | |
download | cpython-e0f04659cd717a031b42dcfd43ca07824b24f9b2.zip cpython-e0f04659cd717a031b42dcfd43ca07824b24f9b2.tar.gz cpython-e0f04659cd717a031b42dcfd43ca07824b24f9b2.tar.bz2 |
Issue #10220: Add inspect.getgeneratorstate(). Initial patch by Rodolpho Eckhardt
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/inspect.rst | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 9a068da..810a95b 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -620,3 +620,25 @@ code execution:: # in which case the descriptor itself will # have to do pass + +Current State of a Generator +---------------------------- + +When implementing coroutine schedulers and for other advanced uses of +generators, it is useful to determine whether a generator is currently +executing, is waiting to start or resume or execution, or has already +terminated. func:`getgeneratorstate` allows the current state of a +generator to be determined easily. + +.. function:: getgeneratorstate(generator) + + Get current state of a generator-iterator. + + Possible states are: + GEN_CREATED: Waiting to start execution. + GEN_RUNNING: Currently being executed by the interpreter. + GEN_SUSPENDED: Currently suspended at a yield expression. + GEN_CLOSED: Execution has completed. + + + |