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.

Title: SystemExit out of run_until_complete causes AttributeError when using python3 -m
Type: Stage:
Components: asyncio Versions: Python 3.4, Python 3.5
Status: closed Resolution: duplicate
Dependencies: Superseder: asyncio: KeyboardInterrupt inside a coroutine causes AttributeError
View: 22428
Assigned To: Nosy List: chrysn, gvanrossum, vstinner, yselivanov
Priority: normal Keywords:

Created on 2014-09-24 11:22 by chrysn, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit chrysn, 2014-09-24 11:22
test.err chrysn, 2014-09-24 11:23 chrysn, 2014-09-24 11:23
Messages (3)
msg227440 - (view) Author: chrysn (chrysn) * Date: 2014-09-24 11:22
the attached snipplet, which runs an asyncio main loop to the completion of a coroutine raising SystemExit, runs cleanly when invoked using `python3`, but shows a logging error from the Task.__del__ method when invoked using `python3 -m test`.

the error message (attached as test.err) indicates that the builtins module has already been emptied by the time the Task's destructor is run.

i could reproduce the problem with an easier test case without asyncio (, but then again, there the issue is slightly more obvious (one could argue a "don't do that, then"), and it occurs no matter how the program is run. i'm leaving this initially assigned to asyncio, because (to the best of my knowledge) does not do bad things by itself, and the behavior is inconsistent only there.
msg227457 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-09-24 14:47
Running "python" and "python -m test" changes how the code is loaded. With "python", becomes the "__main__" module, whereas "python -m test" uses the "test" module.

At Python exit, the __main__ module and other modules are destroyed differently.

Anyway, this issue is another example of the issue #22428 and so I close it as duplicate.
msg228988 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-10-10 11:36
I created a more specific issue for issue #22599. It's not directly related to asyncio.
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66670
2014-10-11 12:38:29vstinnersetstatus: open -> closed
2014-10-10 11:36:53vstinnersetmessages: + msg228988
2014-09-24 14:47:24vstinnersetsuperseder: asyncio: KeyboardInterrupt inside a coroutine causes AttributeError
resolution: duplicate
messages: + msg227457
versions: + Python 3.5
2014-09-24 11:23:29chrysnsetfiles: +
2014-09-24 11:23:08chrysnsetfiles: + test.err
2014-09-24 11:22:41chrysnsetfiles: +
2014-09-24 11:22:12chrysncreate