-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
pytest-trio exits with TrioInternalError on Python 3.7 when pytest-asyncio is installed #126
Comments
The error message means that someone else used
If it is an asyncio bug, I'm not sure what to do. Python 3.7 asyncio isn't going to get fixed. Maybe there's some workaround you can do, like forcibly calling |
Thanks for the clarification! I noticed that I always ran that test as part of our test suite. I then tried running it stand-alone and it completes successfully. I assume the issue is caused by our test setup and we have to figure that out on pytest-asyncio side. It's unclear to me why the error only appears with Python 3.7, though. Thanks! |
My (unconfirmed) guess is that it's because in 3.7, asyncio doesn't cleanup the |
Thanks @njsmith! I think the fix was python/cpython#11135 |
When run with Python 3.7 asyncio.subprocess.create_subprocess_exec seems to be affected by an issue that prevents correct cleanup. Tests using pytest-trio will report that signal handling is already performed by another library and fail. [1] This is possibly a bug in CPython 3.7, so we ignore this test for that Python version. CPython 3.7 uses asyncio.streams.StreamReader and asyncio.streams.StreamWriter to implement asyncio.streams.StreamReaderProtocol and asyncio.subprocess.SubprocessStreamProtocol. StreamReaderProtocol contained cyclic references between the reader and the protocol, which prevented garbage collection. While StreamReaderProtocol received a patch [2], SubprocessStreamProtocol, which is used by create_subprocess_exec, possibly has the same problem, but was not patched as part of CPython 3.7. That's why we ignore this test for CPython 3.7. [1] python-trio/pytest-trio#126 [2] python/cpython#9201 Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
… in strict mode (#307) * test: Package-scoped event_loop fixture no longer leaks into other tests. The expected behaviour is that the `event_loop` fixture defined in `tests/sessionloop/conftest.py` is torn down when all tests in `tests/sessionloop` are complete. Running the tests with the pytest option --setup-show pointed out that the fixture is torn down at the end of the test session, instead. This is an unintended side effect of the sessionloop test which may affect other tests in the test suite. Reducing the fixture scope from "package" to "module" results in the expected behaviour. The module was renamed to reflect the fact that the tests do not use a session scope. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de> * test: Removed test with obsolete "forbid_global_loop". forbid_global_loop was an option to pytest.mark.asyncio which was removed in v0.6.0. The two subprocess tests are otherwise identical. Therefore, one of the tests was removed along with the obsolete option. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de> * test: Ignore subprocess tests when running on CPython 3.7. When run with Python 3.7 asyncio.subprocess.create_subprocess_exec seems to be affected by an issue that prevents correct cleanup. Tests using pytest-trio will report that signal handling is already performed by another library and fail. [1] This is possibly a bug in CPython 3.7, so we ignore this test for that Python version. CPython 3.7 uses asyncio.streams.StreamReader and asyncio.streams.StreamWriter to implement asyncio.streams.StreamReaderProtocol and asyncio.subprocess.SubprocessStreamProtocol. StreamReaderProtocol contained cyclic references between the reader and the protocol, which prevented garbage collection. While StreamReaderProtocol received a patch [2], SubprocessStreamProtocol, which is used by create_subprocess_exec, possibly has the same problem, but was not patched as part of CPython 3.7. That's why we ignore this test for CPython 3.7. [1] python-trio/pytest-trio#126 [2] python/cpython#9201 Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de> * build: Added pytest-trio to the test dependencies. This allows testing compatibility between pytest-trio and pytest-asyncio. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de> * fix: Do not try to initialize async fixtures without explicit asyncio mark in strict mode. This fixes a bug that breaks compatibility with pytest_trio. Closes #298 Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
Thanks for your support! From what I can tell, the problem was related to the use of Btw: We just released pytest-asyncio-0.18.3 which fixes compatibility with pytest-trio :) |
I'm one of the maintainers of pytest-asyncio and I'm currently trying to address a reported incompatibilty between pytest-asyncio and pytest-trio v0.7.0.
The current release of pytest-asyncio (v0.18.2) contains a bug, which causes pytest to fail during the collection phase when the code base contains trio fixtures. I addressed the issue in a branch and came up with a corresponding test case:
The test case is successful on CPython 3.8 – 3.10, but it fails with Python 3.7. The reported error is a
TrioInternalError
. It's worth noting that the test also issues aRuntimeWarning
and suggests to sethost_uses_signal_set_wakeup_fd=True
. However, I didn't find a way to configure this variable in pytest-trio.This is the test output I'm seeing:
You will need to use a Git version of pytest-asyncio to reproduce the issue (see this branch). Run
tox -e py37
in that branch to reproduce the issue.I'm currently trying to figure out whether I'm using pytest-trio incorrectly or whether pytest-trio or pytest-asyncio have to make adjustments to work together nicely. I'm also puzzled why the test only fails on Python 3.7. Do you have any ideas?
The text was updated successfully, but these errors were encountered: