inspect.getgeneratorstate
Prev: inspect.getgeneratorlocals | Up: inspect | Next: inspect.getinnerframes
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getgeneratorstate
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import getgeneratorstate
Signature & Overview
inspect.getgeneratorstate(generator)
Get current state of a generator-iterator.
Usage
import inspect
def gen(): yield 1
g = gen()
assert inspect.getgeneratorstate(g) == inspect.GEN_CREATED
next(g)
assert inspect.getgeneratorstate(g) == inspect.GEN_SUSPENDED
Gotchas
- States:
GEN_CREATED,GEN_RUNNING,GEN_SUSPENDED,GEN_CLOSED.
REPL Inspect
from inspect import getgeneratorstate
help(getgeneratorstate)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/getgeneratorlocals Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/getinnerframes Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/inspect/ArgInfo Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/Arguments Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/Attribute Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BlockFinder Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BoundArguments shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BufferFlags shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/ClassFoundException shared tags: #inspect, #stdlib