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.

classification
Title: __aexit__ is not called when a context manager is used in an async generator
Type: Stage:
Components: asyncio Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Andrey Lemets, asksol, asvetlov, xtreak, yselivanov
Priority: normal Keywords:

Created on 2019-03-27 11:28 by Andrey Lemets, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg338953 - (view) Author: Andrey Lemets (Andrey Lemets) Date: 2019-03-27 11:28
This code (https://gist.github.com/EnotYoyo/d751951c5ff77e22686715aa9ab05b56) works correctly in python3.6.6 but does not in python3.6.8+
msg338954 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-03-27 11:44
Could this be possibly due to issue34769 ? There was another report related to this commit : issue36403

➜  cpython git:(41e5ec377b) git checkout 41e5ec377b && make -s -j4 > /dev/null
HEAD is now at 41e5ec377b bpo-34769: Thread safety for _asyncgen_finalizer_hook(). (GH-9716)
➜  cpython git:(41e5ec377b) ./python.exe ../backups/bpo36449.py
aenter
Traceback (most recent call last):
  File "../backups/bpo36449.py", line 25, in <module>
    loop.run_until_complete(main())
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/asyncio/base_events.py", line 573, in run_until_complete
    return future.result()
  File "../backups/bpo36449.py", line 20, in main
    raise Exception
Exception
➜  cpython git:(41e5ec377b) git checkout 41e5ec377b~1 && make -s -j4 > /dev/null
Previous HEAD position was 41e5ec377b bpo-34769: Thread safety for _asyncgen_finalizer_hook(). (GH-9716)
HEAD is now at 0ce31d340b bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (GH-9656)
➜  cpython git:(0ce31d340b) ./python.exe ../backups/bpo36449.py
aenter
aexit
Traceback (most recent call last):
  File "../backups/bpo36449.py", line 25, in <module>
    loop.run_until_complete(main())
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/asyncio/base_events.py", line 576, in run_until_complete
    return future.result()
  File "../backups/bpo36449.py", line 20, in main
    raise Exception
Exception
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80630
2019-03-27 11:44:22xtreaksetnosy: + asksol, xtreak
messages: + msg338954
2019-03-27 11:28:56Andrey Lemetscreate