You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create inspect introspection functions for asyncgen.
ASYNCGEN_CREATED='ASYNCGEN_CREATED'ASYNCGEN_RUNNING='ASYNCGEN_RUNNING'ASYNCGEN_SUSPENDED='ASYNCGEN_SUSPENDED'ASYNCGEN_CLOSED='ASYNCGEN_CLOSED'defgetasyncgeneratorstate(asyncgenerator):
"""Get current state of a async generator-iterator. Possible states are: ASYNCGEN_CREATED: Waiting to start execution. ASYNCGEN_RUNNING: Currently being executed by the interpreter. ASYNCGEN_SUSPENDED: Currently suspended at a yield expression. ASYNCGEN_CLOSED: Execution has completed. """ifasyncgenerator.ag_running:
returnASYNCGEN_RUNNINGifasyncgenerator.ag_frameisNone:
returnASYNCGEN_CLOSEDifasyncgenerator.ag_frame.f_lasti==-1:
returnASYNCGEN_CREATEDreturnASYNCGEN_SUSPENDEDdefgetasyncgeneratorlocals(asyncgenerator):
""" Get the mapping of async generator local variables to their current values. A dict is returned, with the keys the local variable names and values the bound values."""ifnotisasyncgen(asyncgenerator):
raiseTypeError("{!r} is not a Python generator".format(asyncgenerator))
frame=getattr(asyncgenerator, "ag_frame", None)
ifframeisnotNone:
returnasyncgenerator.ag_frame.f_localselse:
return {}
Activity
animateaprogramming commentedon Apr 1, 2022
Create inspect introspection functions for asyncgen.
tirkarthi commentedon Apr 1, 2022
Seems to be duplicate of https://bugs.python.org/issue35759
kumaraditya303 commentedon Jun 20, 2022
Duplicate of #79940