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.

Created on 2019-01-17 12:34 by tkren, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
0001-inspect-add-introspection-API-for-asynchronous-gener.patch tkren, 2019-01-17 12:34 Initial patch for getasyncgenstate and getasyncgenlocals
Pull Requests
URL Status Linked Edit
PR 11590 open tkren, 2019-01-17 13:20
PR 11590 open tkren, 2019-01-17 13:20
Messages (2)
msg333861 - (view) Author: Thomas Krennwallner (tkren) * Date: 2019-01-17 12:34
The `inspect` module does not contain functions for determining the current state of asynchronous generators. That is, there is no introspection API for asynchronous generators that match the API for generators and coroutines: https://docs.python.org/3.8/library/inspect.html#current-state-of-generators-and-coroutines. I propose to add `inspect.getasyncgenstate` and `inspect.getasyncgenlocals` (following `inspect.isasyncgenfunction` and `inspect.isasyncgen`). % ./python Python 3.8.0a0 (heads/fix-issue-getasyncgenstate:a24deae1e2, Jan 17 2019, 11:44:45) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import inspect >>> async def agen(): ... x = 1 ... yield x ... x += 1 ... yield x ... >>> ag = agen() >>> inspect.getasyncgenstate(ag) 'AGEN_CREATED' >>> inspect.getasyncgenlocals(ag) {} >>> ag.__anext__().__next__() Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration: 1 >>> inspect.getasyncgenstate(ag) 'AGEN_SUSPENDED' >>> inspect.getasyncgenlocals(ag) {'x': 1} >>> ag.__anext__().__next__() Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration: 2 >>> inspect.getasyncgenstate(ag) 'AGEN_SUSPENDED' >>> inspect.getasyncgenlocals(ag) {'x': 2} >>> ag.aclose().send(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration >>> inspect.getasyncgenstate(ag) 'AGEN_CLOSED' >>> inspect.getasyncgenlocals(ag) {}
msg333870 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-01-17 14:15
see also msg300475
History
Date User Action Args
2022-04-11 14:59:10adminsetgithub: 79940
2019-01-17 14:15:35xtreaksetnosy: + yselivanov, xtreak, ncoghlan
messages: + msg333870
2019-01-17 13:20:51tkrensetstage: patch review
pull_requests: + pull_request11285
2019-01-17 13:20:49tkrensetstage: (no value)
pull_requests: + pull_request11284
2019-01-17 12:34:49tkrencreate