-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Tests using invoke_and_assert
can sometimes attempt to forward signals from a thread that's not main
#10895
Comments
Here's a recent example of this failure -- it can occur in many places, not just our CLI commands. My problem with this is that the issue is not only that tests are flaky -- though they are. The problem is that this suggests any code wrapped in
|
This appears to be the root cause: pytest-dev/pytest-xdist#469 |
So it's not just So I’m considering other options: moving signal handler code into a utility that logs when it’s not on the main thread and thus can’t execute signal.signal and revisiting the mocking strategy we use to mock and test signal handler calls. Currently, our mock calls |
I'm working on a minimal repro test case now, having a hard time figuring out when xdist puts things on another thread... |
And they point to the underlying |
I'm still not able to reproduce this, even just a basic test that asserts that the test thread is not the main thread. import threading
import pytest
@pytest.mark.parametrize("anything", list(range(100)))
def test_sync_which_thread_am_i(anything: int):
assert threading.get_ident() == threading.main_thread().ident
@pytest.mark.parametrize("anything", list(range(100)))
async def test_async_which_thread_am_i(anything: int):
assert threading.get_ident() == threading.main_thread().ident My understanding of the
Then in there, I run a couple of things to get bootstrapped:
Then run pytest (with timeouts disabled):
After quite a few tries, I'm not able to get this to happen. I haven't been able to determine what combo of software, Github Actions environment, and system load makes this happen, but I feel like this is starting to narrow in on the issue. |
First check
Description
This was the source of several test flakes that @abrookins identified here: https://github.com/PrefectHQ/prefect/pull/10889/files#diff-00c0a3f9f0ef58527f83db91f74ea7356bb8d9134b4db3e490e4e35d39c49445R12-R16
Impact
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: