[issue21886] asyncio: Future.set_result() called on cancelled Future raises asyncio.futures.InvalidStateError

2014-07-05 Thread STINNER Victor
STINNER Victor added the comment: Fix commited to Tulip (4655ef2d9f43), Python 3.4 and 3.5. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21886 ___

[issue21886] asyncio: Future.set_result() called on cancelled Future raises asyncio.futures.InvalidStateError

2014-07-05 Thread Roundup Robot
Roundup Robot added the comment: New changeset d7e4efd5e279 by Victor Stinner in branch '3.4': Closes #21886, #21447: Fix a race condition in asyncio when setting the result http://hg.python.org/cpython/rev/d7e4efd5e279 New changeset 50c995bdc00a by Victor Stinner in branch 'default': (Merge

[issue21886] asyncio: Future.set_result() called on cancelled Future raises asyncio.futures.InvalidStateError

2014-06-30 Thread STINNER Victor
New submission from STINNER Victor: Ok, I found a way to reproduce the error InvalidStateError in asyncio. I'm not sure that it's the same the error in #21447. Output of attached bug.py in debug mode: --- Exception in callback Future.set_result(None) handle: TimerHandle when=79580.878306285

[issue21886] asyncio: Future.set_result() called on cancelled Future raises asyncio.futures.InvalidStateError

2014-06-30 Thread Ryder Lewis
Changes by Ryder Lewis rle...@softgatesystems.com: -- nosy: +ryder.lewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21886 ___ ___

[issue21886] asyncio: Future.set_result() called on cancelled Future raises asyncio.futures.InvalidStateError

2014-06-30 Thread STINNER Victor
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

[issue21886] asyncio: Future.set_result() called on cancelled Future raises asyncio.futures.InvalidStateError

2014-06-30 Thread STINNER Victor
STINNER Victor added the comment: In https://codereview.appspot.com/69870048/ Guido proposed to test to replace: self._loop.call_soon(waiter.set_result, None) with: if not waiter.cancelled(): waiter.set_result(None) -- ___ Python tracker

[issue21886] asyncio: Future.set_result() called on cancelled Future raises asyncio.futures.InvalidStateError

2014-06-30 Thread STINNER Victor
STINNER Victor added the comment: _maybe_set_result() is not a good name. Other suggestions: _set_result_except_cancelled, _set_result_ignore_cancelled. I read again the mail thread and Guido proposed the nice name _set_result_unless_cancelled() which is very explicit. I updated my patch: