-
Notifications
You must be signed in to change notification settings - Fork 40
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
Fix race condition between ping and stream_response #55
Conversation
Thank you @ejlangev for your PR. It makes a lot of sense. I am about merging it. However I am not sure what exactly the test_ping_concurrency is demonstrating. May I ask you to:
I also merged the latest PR into your branch. Hope this is ok. Regards, |
…hronization.Lock.release() is deprecated
I'll add some comments to the test, basically it would throw a |
Comments added explaining the sequencing and how this tests prevents it because it would raise a |
@ejlangev , due to a new discussion 77 I tried to understand your use-case better and reproduce race conditions on my side. Unfortunately I could not. My understanding is that the |
I think this is true except when one of the coroutines is calling I think a simple performance improvement would be to get rid of |
@ejlangev , I am baffled by your cycle times, chapeau! |
The bad sequence of events was as follows:
stream_response
callssend
to close the request and blocks somewhere within on actually doing the sending which allows other coroutines to run. At this point theping
wakes up from its sleep and also callssend
. This raises an exception because thestream_response
call had tried to close the request but had not yet been able to return in order to cancel everything else.This is relatively unlikely to happen but we were observing it regularly on our API which is doing a lot of SSE responses.