[issue21886] asyncio: Future.set_result() called on cancelled Future raises asyncio.futures.InvalidStateError
STINNER Victor
report at bugs.python.org
Tue Jul 1 01:33:08 CEST 2014
STINNER Victor added the comment:
I see two options to fix this issue:
- add an optional parameter to set_result() to do nothing if the future is cancelled
- add a method (public or private) to set a result or do nothing if the future is cancelled
Patch "Add ignore_cancelled and ignore_done to Future.set_result()" (for Tulip):
http://codereview.appspot.com/109340043
Patch "Add Future._maybe_set_result()":
http://codereview.appspot.com/108300043
I prefer the second patch because it doesn't touch the public API and it is shorter.
Note: the first patch contains unrelated changes, like checking fut.cancelled() instead of fut.done().
"_maybe_set_result()" is not a good name. Other suggestions: "_set_result_except_cancelled", ""_set_result_ignore_cancelled".
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21886>
_______________________________________
More information about the Python-bugs-list
mailing list