-
-
Notifications
You must be signed in to change notification settings - Fork 27
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 client & server are flakey #94
Comments
@njsmith any thoughts on how |
My first thought is that the problem might be from combining You can confirm this using whatever macOS's equivalent of strace is (maybe truss?). If you watch the system call trace for a failing run, you'll see one task so something (maybe a connect in your example above), and then trio will call kqueue to ask the kernel if anything has happened, and the kernel will tell it nope, no new connections to handle or anything. If this is the problem, then there are two workarounds:
To set the threshold, you just set |
@njsmith thank you, that appears to be it I ran different values of autojump_threshold. As far as my 5 yr old Mac i7 laptop (otherwise unloaded), the highest value I could reproduce the error was 1 ms. For my use case I'd be fine setting it at 5 ms globally. How about a pytest-trio config option? |
Be aware that a timeout that works locally may not work if/when you start running things in CI on weirdo cloud machines. We could think about a pytest-trio config option (maybe open an issue there?), but in the mean time you should be able to override pytest-trio's version like: # Put this in a test file to override pytest-trio's version of the fixture locally
# Or in 'conftest.py' in the root of your test suite to override for the whole testsuite
@pytest.fixture
def autojump_clock():
clock = trio.testing.MockClock()
clock.autojump_threshold = 0.005
return clock (You can also give it a different name in case that's less confusing...) |
thank you-- yes conftest.py override is good enough |
Since adopting trio-websocket for both client and server, my project is having random failures in simple tests which use both together.
The failures are rare, and seem to require use of pytest-trio
autojump_clock
(though there are often no sleep calls involved in the tests).Following is the minimal code I can reproduce this with (OS X, needs to run many times). The test simply starts a server, connects a client to it, and exits.
(The function test0 is repeated 9 more times in the file to induce the failure.)
Failure:
The text was updated successfully, but these errors were encountered: