Skip to content

inspect - getasyncgeneratorstate, getasyncgeneratorlocals #91347

Closed as not planned

Description

@animateaprogramming
BPO 47191
Nosy @tirkarthi

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2022-04-01.18:40:34.046>
labels = ['type-feature', 'library', '3.10', '3.11']
title = 'inspect - getasyncgeneratorstate, getasyncgeneratorlocals'
updated_at = <Date 2022-04-01.20:20:37.341>
user = 'https://bugs.python.org/animateaprogramming'

bugs.python.org fields:

activity = <Date 2022-04-01.20:20:37.341>
actor = 'xtreak'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2022-04-01.18:40:34.046>
creator = 'animatea.programming'
dependencies = []
files = []
hgrepos = []
issue_num = 47191
keywords = []
message_count = 2.0
messages = ['416505', '416516']
nosy_count = 2.0
nosy_names = ['xtreak', 'animatea.programming']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue47191'
versions = ['Python 3.10', 'Python 3.11']

Activity

  1. animateaprogramming commented on Apr 1, 2022

    animateaprogrammingmannequin
    MannequinAuthor

    Create inspect introspection functions for asyncgen.

    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 {}
  2. added
    3.11only security fixes
    stdlibStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancement
    on Apr 1, 2022
  3. tirkarthi commented on Apr 1, 2022

    @tirkarthi
    Member

    Seems to be duplicate of https://bugs.python.org/issue35759

  4. transferred this issue fromon Apr 10, 2022
  5. kumaraditya303 commented on Jun 20, 2022

    @kumaraditya303
    Contributor

    Duplicate of #79940

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)end of life3.11only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions