Issue32810
Created on 2018-02-09 19:49 by dabeaz, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| agen.py | dabeaz, 2018-02-10 13:29 | |||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11166 | open | ZackerySpytz, 2018-12-14 19:57 | |
| Messages (7) | |||
|---|---|---|---|
| msg311906 - (view) | Author: David Beazley (dabeaz) | Date: 2018-02-09 19:49 | |
Libraries such as Curio and asyncio provide a debugging facility that allows someone to view the call stack of generators/coroutines. For example, the _task_get_stack() function in asyncio/base_tasks.py. This works by manually walking up the chain of coroutines (by following cr_frame and gi_frame links as appropriate). The only problem is that it doesn't work if control flow falls into an async generator because an "async_generator_asend" instance is encountered and there is no meaningful way to proceed any further with stack inspection. This problem could be fixed if "async_generator_asend" and "async_generator_athrow" instances exposed the underlying "ags_gen" and "agt_gen" attribute that's held inside the corresponding C structures in Objects/genobject.c. Note: I made a quick and dirty "hack" to Python to extract "ags_gen" and verified that having this information would allow me to get complete stack traces in Curio. |
|||
| msg311946 - (view) | Author: Andrew Svetlov (asvetlov) * ![]() |
Date: 2018-02-10 09:51 | |
Make sense at first glaze. |
|||
| msg311950 - (view) | Author: David Beazley (dabeaz) | Date: 2018-02-10 13:29 | |
I've attached a file that illustrates the issue. (Side thought: this would be nice to have in inspect or traceback) |
|||
| msg331860 - (view) | Author: Zackery Spytz (ZackerySpytz) * ![]() |
Date: 2018-12-14 19:58 | |
I've created a PR for this issue. |
|||
| msg331903 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2018-12-15 15:32 | |
Please don't merge the PR. I'll need some time to think about this before giving it a green light. |
|||
| msg335376 - (view) | Author: Joshua Oreman (Joshua Oreman) | Date: 2019-02-12 23:29 | |
I also ran into this. My workaround was to use gc.get_referents() on the async_generator_asend object, which returns a one-element list containing the async generator object. I don't know if this is guaranteed or just happened to work in the cases I was using it, but it might be good enough? |
|||
| msg349266 - (view) | Author: George Zhang (GeeTransit) * | Date: 2019-08-08 22:49 | |
Also, while the PEP first introducing asynchronous generators stated that its .asend() and .athrow() methods will return a "coroutine-like object", it doesn't allow any introspection into its state or parent async generator. My workaround was to wrap the .asend() and other methods with another coroutine that just awaits and returns the result. Having a better way to check its state and frame will bring it closer to a coroutine. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:57 | admin | set | github: 76991 |
| 2021-01-02 02:42:35 | dabeaz | set | status: open -> closed stage: patch review -> resolved |
| 2019-08-08 22:49:19 | GeeTransit | set | nosy:
+ GeeTransit messages: + msg349266 |
| 2019-02-12 23:29:16 | Joshua Oreman | set | nosy:
+ Joshua Oreman messages: + msg335376 |
| 2018-12-15 15:32:38 | yselivanov | set | messages: + msg331903 |
| 2018-12-14 19:58:26 | ZackerySpytz | set | nosy:
+ ZackerySpytz messages:
+ msg331860 |
| 2018-12-14 19:57:39 | ZackerySpytz | set | keywords:
+ patch stage: patch review pull_requests: + pull_request10403 |
| 2018-09-20 02:45:19 | kdart | set | nosy:
+ kdart |
| 2018-02-11 02:35:12 | xgdomingo | set | nosy:
+ xgdomingo |
| 2018-02-10 13:29:06 | dabeaz | set | files:
+ agen.py messages: + msg311950 |
| 2018-02-10 09:51:35 | asvetlov | set | messages: + msg311946 |
| 2018-02-10 00:35:50 | pablogsal | set | components: + asyncio |
| 2018-02-09 21:52:55 | njs | set | nosy:
+ giampaolo.rodola, njs, asvetlov, yselivanov |
| 2018-02-09 21:17:09 | yarkot | set | nosy:
+ yarkot |
| 2018-02-09 19:49:33 | dabeaz | create | |

