Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue30508

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:"Task exception was never retrieved" reported for a canceled task
Type:behaviorStage:resolved
Components:asyncioVersions:Python 3.7, Python 3.6, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: Miguel Grinberg, ned.deily, yselivanov
Priority:normalKeywords:

Created on2017-05-30 02:14 byMiguel Grinberg, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
never-retrieved.pyMiguel Grinberg,2017-05-30 02:14
Pull Requests
URLStatusLinkedEdit
PR 2050mergedyselivanov,2017-06-09 23:07
PR 2109mergedyselivanov,2017-06-11 13:38
PR 2110mergedyselivanov,2017-06-11 13:48
Messages (7)
msg294732 -(view)Author: Miguel Grinberg (Miguel Grinberg)Date: 2017-05-30 02:14
I am seeing a strange issue that occurs when a task that is awaiting an asyncio.wait_for() is cancelled. I created a simple example that I think demonstrates the issue, even though it isn't exactly how it manifests on my application.When I run the attached script never-retrieved.py I get the following error:Task exception was never retrievedfuture: <Task finished coro=<crash() done, defined at never-retrieved.py:4> exception=ZeroDivisionError('division by zero',)>Traceback (most recent call last):  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step    result = coro.send(None)  File "never-retrieved.py", line 5, in crash    a = 1/0ZeroDivisionError: division by zeroYou can see in the script that the future was cancelled, but the cancel() call was made after the task finished in a zero division error. I think the cancel() call should update the internal state of the future so that the "exception was never retrieved" error does not appear.My application has a more complex setup that I have been unable to reproduce with a simple example. I have a task that is waiting on asyncio.wait_for(fut, timeout), with fut subsequently waiting on a websocket server's receive function. When the websocket client closes the connection, a bunch of cancellations happen, but this future inside the wait_for call crashes before wait_for gets to call cancel() on it. Even though I need to investigate this crash, the fact is that wait_for did cancel this future, but because it already ended in an error the "never retried" error is reported anyway.
msg294733 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2017-05-30 02:15
Yes, this is a known problem to me, thank you for creating the issue. Will work on a fix soon.
msg295708 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2017-06-11 13:49
New changeset7ce1c6fb579a01bb184224a10019039fde9c8eaf by Yury Selivanov in branch 'master':bpo-30508: Don't log exceptions if Task/Future "cancel()" method called (#2050)https://github.com/python/cpython/commit/7ce1c6fb579a01bb184224a10019039fde9c8eaf
msg295709 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2017-06-11 14:00
New changeset176f2ebdad93f20876c08efabd364a0e6c86de14 by Yury Selivanov in branch '3.6':bpo-30508: Don't log exceptions if Task/Future "cancel()" method was called. (#2109)https://github.com/python/cpython/commit/176f2ebdad93f20876c08efabd364a0e6c86de14
msg295711 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2017-06-11 14:11
New changesetd24c8287e226ac9983caf6bb826a7b53142ee31f by Yury Selivanov in branch '3.5':bpo-30508: Don't log exceptions if Task/Future "cancel()" method was called. (#2110)https://github.com/python/cpython/commit/d24c8287e226ac9983caf6bb826a7b53142ee31f
msg295712 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2017-06-11 14:12
Fixed.  Ned, this will be included in 3.6.2, right?
msg295721 -(view)Author: Ned Deily (ned.deily)*(Python committer)Date: 2017-06-11 15:42
Yury, yes (3.6.2 cutoff is about 24 hours from now)
History
DateUserActionArgs
2022-04-11 14:58:47adminsetgithub: 74693
2017-06-11 15:42:01ned.deilysetmessages: +msg295721
2017-06-11 14:12:51yselivanovsetstatus: open -> closed

versions: + Python 3.7
nosy: +ned.deily

messages: +msg295712
resolution: fixed
stage: resolved
2017-06-11 14:11:49yselivanovsetmessages: +msg295711
2017-06-11 14:00:16yselivanovsetmessages: +msg295709
2017-06-11 13:49:20yselivanovsetmessages: +msg295708
2017-06-11 13:48:42yselivanovsetpull_requests: +pull_request2163
2017-06-11 13:38:11yselivanovsetpull_requests: +pull_request2162
2017-06-09 23:07:57yselivanovsetpull_requests: +pull_request2112
2017-05-30 02:15:28yselivanovsetmessages: +msg294733
2017-05-30 02:14:06Miguel Grinbergcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp