This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author animatea.programming
Recipients animatea.programming
Date 2022-04-01.18:40:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1648838434.06.0.105356419034.issue47191@roundup.psfhosted.org>
In-reply-to
Content
Create inspect introspection functions for asyncgen.

```py
ASYNCGEN_CREATED = 'ASYNCGEN_CREATED'
ASYNCGEN_RUNNING = 'ASYNCGEN_RUNNING'
ASYNCGEN_SUSPENDED = 'ASYNCGEN_SUSPENDED'
ASYNCGEN_CLOSED = 'ASYNCGEN_CLOSED'

def getasyncgeneratorstate(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.
    """
    if asyncgenerator.ag_running:
        return ASYNCGEN_RUNNING
    if asyncgenerator.ag_frame is None:
        return ASYNCGEN_CLOSED
    if asyncgenerator.ag_frame.f_lasti == -1:
        return ASYNCGEN_CREATED
    return ASYNCGEN_SUSPENDED


def getasyncgeneratorlocals(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."""

    if not isasyncgen(asyncgenerator):
        raise TypeError("{!r} is not a Python generator".format(asyncgenerator))

    frame = getattr(asyncgenerator, "ag_frame", None)
    if frame is not None:
        return asyncgenerator.ag_frame.f_locals
    else:
        return {}
```
History
Date User Action Args
2022-04-01 18:40:34animatea.programmingsetrecipients: + animatea.programming
2022-04-01 18:40:34animatea.programmingsetmessageid: <1648838434.06.0.105356419034.issue47191@roundup.psfhosted.org>
2022-04-01 18:40:34animatea.programminglinkissue47191 messages
2022-04-01 18:40:33animatea.programmingcreate