Skip to content
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

Wait for client on test_connection_lost_before_handshake_complete #2001

Merged
merged 17 commits into from
Jun 10, 2023

Conversation

Kludex
Copy link
Sponsor Member

@Kludex Kludex commented Jun 8, 2023

This PR solves the flakyness on test_connection_lost_before_handshake_complete.

@Kludex Kludex marked this pull request as draft June 8, 2023 18:48
@Kludex Kludex marked this pull request as ready for review June 8, 2023 19:05
@Kludex

This comment was marked as spam.

@Kludex Kludex requested a review from a team June 8, 2023 19:11
task = asyncio.create_task(
websocket_session(f"ws://127.0.0.1:{unused_tcp_port}")
)
asyncio.create_task(websocket_session(f"ws://127.0.0.1:{unused_tcp_port}"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the task = is important please keep it

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important when you don't want the GC to clean it, since it's a weak ref, but in this case since all the logic happens in the same function scope, I don't think I need it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's been a while so I dont remember exactly but when I reworked the whole test suite and added strict settings to pytest this helped a lot.

@Kludex Kludex requested a review from euri10 June 9, 2023 06:57
@Kludex
Copy link
Sponsor Member Author

Kludex commented Jun 9, 2023

The test is hanging. I'm investigating.

@Kludex
Copy link
Sponsor Member Author

Kludex commented Jun 9, 2023

The test is hanging at await response_received.wait(), but I'm not sure what's the race condition here... 🤔

@Kludex
Copy link
Sponsor Member Author

Kludex commented Jun 9, 2023

It looks like the success rate increases with a print 🤣

scripts/test Outdated Show resolved Hide resolved
tests/protocols/test_websocket.py Outdated Show resolved Hide resolved
@@ -749,12 +749,13 @@ async def websocket_session(uri):
)
await asyncio.sleep(0.1)
send_accept_task.set()
await asyncio.sleep(0.1)
Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this tick was needed 😄

@Kludex
Copy link
Sponsor Member Author

Kludex commented Jun 10, 2023

I've run the same commit 8x, and it passed on all of them. Should be fine now (...or I'm lucky). 👍

@Kludex Kludex merged commit 3737d66 into master Jun 10, 2023
15 checks passed
@Kludex Kludex deleted the fix/flaky-test branch June 10, 2023 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants