-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subprocess causes errors in asyncio.subprocess #114
Comments
Python 3.8+ doesn't have this problem with the default configuration. |
I can confirm that the provided example fails on CPython 3.7, but succeeds with CPython>=3.8 (tested on Linux x86_64). CPython 3.7 will be end of life roughly 9 months from now (see PEP 537). Child watchers are currently being deprecated (see python/cpython#94597) and are scheduled for removal in Python 3.14. If you are affected by this issue, your best course of action will likely be upgrading to a new Python version. I'll close this issue as "won't fix" since the pytest-asyncio maintainers are unlikely to implement the backport of said child watcher. If anyone has a different opinion on the matter, please reopen the issue. We'll consider pull requests. |
TLDR;
when combining async and sync testcases that use subprocesses, the IOloop childwatcher is not correctly closed.
workaround included
How to reproduce
the second testcase fails if it is run after the first one
Reason
When using asyncio.subprocess, a self-pipe is created. The python interpreter writes to this pipe whenever a signal arrives.
When the pipe is not read (e.g. when the ioloop is not running), it fills up, when it is full and new signals arrive, the interpreter panics.
If the IOloop is stopped, the pipe is detached. However, when the IOloop is replaced, the childwatcher is moved to the new ioloop. The new IOloop will then attach a new pipe.
Before pytest_asyncio stops the ioloop, it first reinstalls the old ioloop.
This causes the self-pipe to remain attached and fill up with junk, causing the interperter to panic.
Workaround
Solution
I think the child_watcher reset could also be included in the pytest_asyncio fixtures as well
The text was updated successfully, but these errors were encountered: