[issue23140] InvalidStateError on asyncio subprocess task cancelled
Xavier de Gaye added the comment: Thanks Xavier for the bug report, it should now be fixed. Works fine with me. Thanks for the patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23140 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23140] InvalidStateError on asyncio subprocess task cancelled
STINNER Victor added the comment: Oh no. My comment was not published, it was probably an issue with my unstable Internet connection. Here is a patch fixing the issue with an unit test. There is another call to Future.set_result() in subprocess.py not protected by an if in connection_made(). I don't know if it should be patched too or not. -- keywords: +patch Added file: http://bugs.python.org/file37606/asyncio_subprocess_cancel_wait.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23140 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23140] InvalidStateError on asyncio subprocess task cancelled
Guido van Rossum added the comment: The patch looks good, although the test feels overly complex (but maybe I'm missing something). I'm okay with leaving the other unguarded set_result() call unchanged, but I'm also okay with putting if not self.waiter.cancelled(): around it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23140 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23140] InvalidStateError on asyncio subprocess task cancelled
STINNER Victor added the comment: Thanks Xavier for the bug report, it should now be fixed. Sorry, I don't see any workaround right now (except of using the development version of Tulip). The patch looks good, although the test feels overly complex (but maybe I'm missing something). Oh, I commited the change before seeing that you posted a review on Rietveld. I modified the unit test to simplify it, the new code is enough to trigger the bug. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23140 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23140] InvalidStateError on asyncio subprocess task cancelled
Roundup Robot added the comment: New changeset 990ce80d8283 by Victor Stinner in branch '3.4': Issue #23140, asyncio: Simplify the unit test https://hg.python.org/cpython/rev/990ce80d8283 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23140 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23140] InvalidStateError on asyncio subprocess task cancelled
STINNER Victor added the comment: I'm okay with leaving the other unguarded set_result() call unchanged, but I'm also okay with putting if not self.waiter.cancelled(): around it. While playing with asyncio to try to inject errors on this code path, I found even more severe issues: see the issue #23173 which proposes to fix them. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23140 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23140] InvalidStateError on asyncio subprocess task cancelled
Roundup Robot added the comment: New changeset 7c9b9d2514bb by Victor Stinner in branch '3.4': Issue #23140, asyncio: Fix cancellation of Process.wait(). Check the state of https://hg.python.org/cpython/rev/7c9b9d2514bb -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23140 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23140] InvalidStateError on asyncio subprocess task cancelled
Xavier de Gaye added the comment: The exception is not raised when loop.set_debug(False) on my linux box. So I guess this may be not reproductible on all platforms. The new attached test_cancel_2.py raises an exception while asyncio debug is false, by forcing one more iteration of the loop after the pending tasks list is empty. Also with asyncio debug false and with test_cancel_2.py and after removing the last task from the initial tasks list (i.e. asyncio.Task(asyncio.sleep(10))): * with more_iterations = 2: the exception is raised, not often * with more_iterations = 3: the exception is raised, seemingly always * with more_iterations = 0: another exception, often; Exception ignored when trying to write to the signal wakeup fd: OSError: [Errno 9] Bad file descriptor -- Added file: http://bugs.python.org/file37580/test_cancel_2.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23140 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23140] InvalidStateError on asyncio subprocess task cancelled
New submission from Xavier de Gaye: The attached test_cancel.py script prints the following error: Exception in callback SubprocessStreamProtocol.process_exited() handle: Handle SubprocessStreamProtocol.process_exited() created at Lib/asyncio/base_subprocess.py:130 source_traceback: Object created at (most recent call last): File test_cancel.py, line 37, in module loop.run_until_complete(main_task) File Lib/asyncio/base_events.py, line 286, in run_until_complete self.run_forever() File Lib/asyncio/base_events.py, line 258, in run_forever self._run_once() File Lib/asyncio/base_events.py, line 1102, in _run_once handle._run() File Lib/asyncio/events.py, line 120, in _run self._callback(*self._args) File Lib/asyncio/base_subprocess.py, line 146, in _process_exited self._call(self._protocol.process_exited) File Lib/asyncio/base_subprocess.py, line 130, in _call self._loop.call_soon(cb, *data) Traceback (most recent call last): File Lib/asyncio/events.py, line 120, in _run self._callback(*self._args) File Lib/asyncio/subprocess.py, line 99, in process_exited waiter.set_result(returncode) File Lib/asyncio/futures.py, line 338, in set_result raise InvalidStateError('{}: {!r}'.format(self._state, self)) asyncio.futures.InvalidStateError: CANCELLED: Future cancelled created at Lib/asyncio/subprocess.py:126 -- components: asyncio files: test_cancel.py messages: 233237 nosy: giampaolo.rodola, gvanrossum, haypo, pitrou, xdegaye, yselivanov priority: normal severity: normal status: open title: InvalidStateError on asyncio subprocess task cancelled type: behavior versions: Python 3.5 Added file: http://bugs.python.org/file37571/test_cancel.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23140 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com