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: asyncio: check if a future is cancelled before calling set_result/set_exception
Type: Stage:
Components: asyncio Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, python-dev, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2015-01-09 00:11 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
asyncio.patch vstinner, 2015-01-09 00:11 review
Messages (7)
msg233699 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-01-09 00:11
set_result/set_exception methods of an asyncio.Future raise an exception if the future is cancelled.

Attached patch adds the check in 3 remaining places.
msg233703 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-01-09 00:52
Oh, I forgot that the change in subprocess.py (check if waiter is cancelled before setting its result) is already part of the issue #23197 which comes with an unit test.

The changes on the SSL handshake are still needed.
msg233985 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-01-14 01:17
> Oh, I forgot that the change in subprocess.py (check if waiter is cancelled before setting its result) is already part of the issue #23197 which comes with an unit test.

Wrong, it's the issue #23173.
msg233986 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-01-14 01:19
The sslproto.py which just has been merged has a similar issue:

            if isinstance(exc, Exception):
                if self._waiter is not None:
                    self._waiter.set_exception(exc)

in _on_handshake_complete().
msg234034 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-01-14 16:15
New changeset 42f4dfc6c6a9 by Victor Stinner in branch '3.4':
Issue #23197: On SSL handshake failure on matching hostname, check if the
https://hg.python.org/cpython/rev/42f4dfc6c6a9
msg234035 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-01-14 16:15
New changeset c9ad45b15919 by Victor Stinner in branch '3.4':
Issue #23197, asyncio: On SSL handshake failure, check if the waiter is
https://hg.python.org/cpython/rev/c9ad45b15919
msg234036 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-01-14 16:16
Ok, I commited my changes to Python 3.4, Python 3.5 and Tulip. All calls to set_result/set_exception should now be protected by a check on the future state.

There is now a new class of bugs, but it's a different issue:
https://code.google.com/p/tulip/issues/detail?id=218

I close this issue.
History
Date User Action Args
2022-04-11 14:58:11adminsetgithub: 67386
2015-01-14 16:16:41vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg234036
2015-01-14 16:15:31python-devsetmessages: + msg234035
2015-01-14 16:15:29python-devsetnosy: + python-dev
messages: + msg234034
2015-01-14 01:19:51vstinnersetmessages: + msg233986
2015-01-14 01:17:25vstinnersetmessages: + msg233985
2015-01-09 00:52:56vstinnersetmessages: + msg233703
2015-01-09 00:11:52vstinnercreate