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: Coroutine is awaited despite an exception in run_until_complete()
Type: behavior Stage: resolved
Components: asyncio Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: asvetlov Nosy List: asvetlov, dkaveshnikov, miss-islington, xtreak, yselivanov
Priority: normal Keywords: patch

Created on 2020-01-02 13:34 by dkaveshnikov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_event_loop.py dkaveshnikov, 2020-01-02 13:34 Snippet
Pull Requests
URL Status Linked Edit
PR 17796 merged asvetlov, 2020-01-02 15:29
PR 17820 merged asvetlov, 2020-01-04 09:16
PR 17821 merged asvetlov, 2020-01-04 09:24
PR 17863 merged asvetlov, 2020-01-06 12:03
PR 17894 merged asvetlov, 2020-01-07 13:25
PR 17895 closed asvetlov, 2020-01-07 13:28
Messages (9)
msg359196 - (view) Author: Kaveshnikov Denis (dkaveshnikov) Date: 2020-01-02 13:34
Hi, I found that if to call run_until_complete() in the task while the event loop will be running, a coroutine sent to run_until_complete() will be performed despite the exception raised from run_until_complete().
It seems to me, it would be better to cancel such a coroutine or just do nothing with it.
msg359201 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-01-02 15:25
Agree, this is a bug.
msg359281 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-01-04 09:49
New changeset 867d8333ce6a7f74191ad464acc609d4a04e4acb by Andrew Svetlov in branch '3.8':
[3.8] bpo-39191: Don't spawn a task before failing (GH-17796) (GH-17820)
https://github.com/python/cpython/commit/867d8333ce6a7f74191ad464acc609d4a04e4acb
msg359282 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-01-04 09:49
New changeset 9c145e19fba53369da5cd23a1e71de489836f827 by Andrew Svetlov in branch '3.7':
[3.7] bpo-39191: Don't spawn a task before failing (GH-17796) (#17821)
https://github.com/python/cpython/commit/9c145e19fba53369da5cd23a1e71de489836f827
msg359415 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-01-06 10:24
This commit seems to generate some warnings in the nested run_until_complete test. The check for running loop is now done at run_until_complete itself before going through the below code in it to create a future and raised a RuntimeError by run_forever as the test used to do. Not sure why CI doesn't have these warnings.

PYTHONWARNINGS=always ./python.exe -m test test_asyncio -m test_run_until_complete_nesting
0:00:00 load avg: 2.16 Run tests sequentially
0:00:00 load avg: 2.16 [1/1] test_asyncio
/Users/kasingar/stuff/python/cpython/Lib/traceback.py:220: RuntimeWarning: coroutine 'EventLoopTestsMixin.test_run_until_complete_nesting.<locals>.coro1' was never awaited
  tb.tb_frame.clear()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/Users/kasingar/stuff/python/cpython/Lib/traceback.py:220: RuntimeWarning: coroutine 'EventLoopTestsMixin.test_run_until_complete_nesting.<locals>.coro1' was never awaited
  tb.tb_frame.clear()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/Users/kasingar/stuff/python/cpython/Lib/traceback.py:220: RuntimeWarning: coroutine 'EventLoopTestsMixin.test_run_until_complete_nesting.<locals>.coro1' was never awaited
  tb.tb_frame.clear()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

== Tests result: SUCCESS ==

1 test OK.

Total duration: 164 ms
Tests result: SUCCESS
msg359417 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-01-06 11:48
Ooh, you are right.
The warning is printed only, test runner thinks that the test is ok.
I'll prepare a quick fix.
msg359418 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-01-06 11:48
Thanks for the report!
msg359509 - (view) Author: miss-islington (miss-islington) Date: 2020-01-07 13:23
New changeset 10ac0cded26d91c3468e5e5a87cecad7fc0bcebd by Miss Islington (bot) (Andrew Svetlov) in branch 'master':
bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863)
https://github.com/python/cpython/commit/10ac0cded26d91c3468e5e5a87cecad7fc0bcebd
msg359513 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-01-07 14:55
New changeset 4112a3da2e01ecc19e9f54b8ac7b383b6f5e85c8 by Andrew Svetlov in branch '3.8':
[3.8] bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863) (#17894)
https://github.com/python/cpython/commit/4112a3da2e01ecc19e9f54b8ac7b383b6f5e85c8
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83372
2020-01-07 14:55:35asvetlovsetstatus: open -> closed
stage: patch review -> resolved
2020-01-07 14:55:22asvetlovsetmessages: + msg359513
2020-01-07 13:28:24asvetlovsetpull_requests: + pull_request17305
2020-01-07 13:25:47asvetlovsetpull_requests: + pull_request17304
2020-01-07 13:23:08miss-islingtonsetnosy: + miss-islington
messages: + msg359509
2020-01-06 12:03:12asvetlovsetstage: resolved -> patch review
pull_requests: + pull_request17280
2020-01-06 11:48:35asvetlovsetmessages: + msg359418
2020-01-06 11:48:24asvetlovsetstatus: closed -> open
assignee: asvetlov
messages: + msg359417
2020-01-06 10:24:05xtreaksetnosy: + xtreak
messages: + msg359415
2020-01-04 09:49:51asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-01-04 09:49:36asvetlovsetmessages: + msg359282
2020-01-04 09:49:22asvetlovsetmessages: + msg359281
2020-01-04 09:24:36asvetlovsetpull_requests: + pull_request17247
2020-01-04 09:16:02asvetlovsetpull_requests: + pull_request17246
2020-01-02 15:29:45asvetlovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request17231
2020-01-02 15:25:25asvetlovsetmessages: + msg359201
versions: + Python 3.8, Python 3.9
2020-01-02 13:34:18dkaveshnikovcreate