Closed seifertm closed 2 years ago
cc @smurfix @oremanj @njsmith
The error message means that someone else used signal.set_wakeup_fd
to register a signal-delivery fd before starting trio. This is weird, because there should only be a signal-delivery fd set while an async loop is running. So... assuming asyncio is the one who registered this library, my guess is either:
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 signal.set_wakeup_fd(-1)
to clear out the stale state? Or just tell people they should upgrade to 3.8+?
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!
It's unclear to me why the error only appears with Python 3.7, though.
My (unconfirmed) guess is that it's because in 3.7, asyncio doesn't cleanup the set_signal_fd
when the loop exits, and then they fixed that in 3.8.
Thanks @njsmith! I think the fix was https://github.com/python/cpython/pull/11135
Thanks for your support!
From what I can tell, the problem was related to the use of asyncio.subprocess.create_subprocess_exec
in our test suite. The underlying implementation changed quite a bit from CPython 3.7 to 3.8, which is probably why recent Python versions behave differently.
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?