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: asyncio: pending call to loop.stop() if a coroutine raises a BaseException
Type: Stage: resolved
Components: asyncio Versions: Python 3.4, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, python-dev, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2014-09-17 11:51 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit vstinner, 2014-09-17 11:51
run_until_complete_baseexception.patch vstinner, 2014-11-28 23:30 review
Messages (4)
msg226994 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-09-17 11:51
Attached script stops immediatly whereas I would expect that the second call to run_forever() keeps running. If you execute the script, you will see:

deque([<Handle _raise_stop_error() at /home/haypo/prog/python/default/Lib/asyncio/>])

The first call to run_forever() keeps a pending call to loop.stop() (to _rase_stop_error() in fact).

I don't know if it should be called a bug or if this surprising behaviour should be documented.

See also the issue #22428.
msg231840 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-11-28 23:30
Here is a simple patch which fixes this specific issue.
msg232165 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-12-05 00:45
New changeset 83bddbfbd3a4 by Victor Stinner in branch '3.4':
Closes #22429, asyncio: Fix EventLoop.run_until_complete(), don't stop the
msg256751 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2015-12-20 06:47
FWIW I think this is now fixed differently, because we reimplemented stop() to use a flag on the loop that's checked by _run_once(), rather than raising an exception. _run_until_complete_cb() can be reduced to simply call fut._loop.stop(). (At least, all tests still pass. :-)
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66619
2015-12-20 06:47:25gvanrossumsetmessages: + msg256751
2014-12-05 00:45:35python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg232165

resolution: fixed
stage: resolved
2014-11-28 23:30:12vstinnersetfiles: + run_until_complete_baseexception.patch
keywords: + patch
messages: + msg231840
2014-09-17 11:51:54vstinnercreate