homepage

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: SystemExit out of run_until_complete causes AttributeError when using python3 -m
Type: Stage:
Components: asyncio Versions: Python 3.4, Python 3.5
process
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.

Files
File name Uploaded Description Edit
test.py chrysn, 2014年09月24日 11:22
test.err chrysn, 2014年09月24日 11:23
destructortest.py chrysn, 2014年09月24日 11:23
Messages (3)
msg227440 - (view) Author: chrysn (chrysn) * Date: 2014年09月24日 11:22
the attached test.py snipplet, which runs an asyncio main loop to the completion of a coroutine raising SystemExit, runs cleanly when invoked using `python3 test.py`, 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 (destructoretest.py), 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) test.py 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 test.py" and "python -m test" changes how the code is loaded. With "python test.py", test.py 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 destructortest.py: issue #22599. It's not directly related to asyncio.
History
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: + destructortest.py
2014年09月24日 11:23:08chrysnsetfiles: + test.err
2014年09月24日 11:22:41chrysnsetfiles: + test.py
2014年09月24日 11:22:12chrysncreate

AltStyle によって変換されたページ (->オリジナル) /