classification
Title: Async generator might re-throw GeneratorExit on aclose()
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: vxgmichel
Priority: normal Keywords: patch

Created on 2018-12-04 13:21 by vxgmichel, last changed 2018-12-04 13:22 by vxgmichel.

Files
File name Uploaded Description Edit
example.py vxgmichel, 2018-12-04 13:21 Reproduce the issue with asyncio
test.py vxgmichel, 2018-12-04 13:22 Reproduce the issue without asyncio
patch.diff vxgmichel, 2018-12-04 13:22 A possible fix
Messages (1)
msg331043 - (view) Author: Vincent Michel (vxgmichel) * Date: 2018-12-04 13:21
As far as I can tell, this issue is different than: https://bugs.python.org/issue34730

I noticed `async_gen.aclose()` raises a GeneratorExit exception if the async generator finalization awaits and silence a failing unfinished future (see example.py).

This seems to be related to a bug in `async_gen_athrow_throw`. In fact, `async_gen.aclose().throw(exc)` does not silence GeneratorExit exceptions. This behavior can be reproduced without asyncio (see test.py).

Attached is a possible patch, although I'm not too comfortable messing with the python C internals. I can make a PR if necessary.
History
Date User Action Args
2018-12-04 13:22:28vxgmichelsetfiles: + patch.diff
keywords: + patch
2018-12-04 13:22:10vxgmichelsetfiles: + test.py
2018-12-04 13:21:20vxgmichelcreate