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.
Created on 2014年12月31日 09:56 by xdegaye, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| test_cancel.py | xdegaye, 2014年12月31日 09:56 | |||
| test_cancel_2.py | xdegaye, 2015年01月01日 12:02 | |||
| asyncio_subprocess_cancel_wait.patch | vstinner, 2015年01月05日 21:42 | review | ||
| Messages (9) | |||
|---|---|---|---|
| msg233237 - (view) | Author: Xavier de Gaye (xdegaye) * (Python triager) | Date: 2014年12月31日 09:56 | |
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> |
|||
| msg233281 - (view) | Author: Xavier de Gaye (xdegaye) * (Python triager) | Date: 2015年01月01日 12:02 | |
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 |
|||
| msg233480 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2015年01月05日 21:42 | |
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. |
|||
| msg233483 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2015年01月05日 23:18 | |
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. |
|||
| msg233487 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2015年01月06日 00:01 | |
> 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. |
|||
| msg233491 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2015年01月06日 00:14 | |
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 |
|||
| msg233492 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2015年01月06日 00:23 | |
New changeset 990ce80d8283 by Victor Stinner in branch '3.4': Issue #23140, asyncio: Simplify the unit test https://hg.python.org/cpython/rev/990ce80d8283 |
|||
| msg233493 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2015年01月06日 00:25 | |
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. |
|||
| msg233512 - (view) | Author: Xavier de Gaye (xdegaye) * (Python triager) | Date: 2015年01月06日 10:39 | |
> Thanks Xavier for the bug report, it should now be fixed. Works fine with me. Thanks for the patch. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:11 | admin | set | github: 67329 |
| 2015年01月06日 10:39:03 | xdegaye | set | messages: + msg233512 |
| 2015年01月06日 00:25:59 | vstinner | set | status: open -> closed resolution: fixed messages: + msg233493 |
| 2015年01月06日 00:23:57 | python-dev | set | messages: + msg233492 |
| 2015年01月06日 00:14:58 | python-dev | set | nosy:
+ python-dev messages: + msg233491 |
| 2015年01月06日 00:01:38 | vstinner | set | messages: + msg233487 |
| 2015年01月05日 23:18:26 | gvanrossum | set | messages: + msg233483 |
| 2015年01月05日 21:42:53 | vstinner | set | files:
+ asyncio_subprocess_cancel_wait.patch keywords: + patch messages: + msg233480 |
| 2015年01月01日 12:02:09 | xdegaye | set | files:
+ test_cancel_2.py messages: + msg233281 |
| 2014年12月31日 09:56:13 | xdegaye | create | |