-
-
Notifications
You must be signed in to change notification settings - Fork 521
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
Unable to StreamWriter.drain() #16
Comments
I have no idea. Unfortunately, my crystal ball is momentarily out of order, so I can't read the code you have carefully omitted from this bug report. |
Regardless of how you're running into this problem, make sure you're using the latest version of asyncio or try your code with Python 3.4, as some bugs have been fixed recently in this area. |
For information, I came across this problem using websockets==3.2 while I was trying to use many "await websocket.send(data)" in parallel. WebSocketCommonProtocol.send() calls asyncio.StreamWriter.drain() which apparently must not be called twice in parallel. I was able to reproduce it without websockets and opened an issue here: http://bugs.python.org/issue29930 |
Thanks @metathink, great investatigation! |
I'm glad to see this being reopened. I've been investigating this on and off for the past 2 weeks and came to the same conclusion: I've been a able to reliably force the bug using https://github.com/mariusae/trickle (with a few local fixes to make it work with CLOEXEC sockets that python uses) to slow down network write speeds, which forces the sender to fill up the write buffer, thus revealing the bug. The patch above simply adds a lock around I've also been reading njs's "post async/await" post and the more I think about it, a module like websocket (and many others, really) could probably do away with all the whole |
Thanks for the patch, let's do that. Even if the issue eventually gets fixed in Python, we need to work around it in versions of Python where it exists. |
See #170 for the more general considerations. |
@RemiCardona Once you merge your patch, it would be a good time to make a release, wouldn't it? |
I released version 3.3 with this change. |
As of CPython 3.6.1, drain() is not coroutine-safe so put a lock around it to make sure it only ever gets called from a single coroutine at a time. http://bugs.python.org/issue29930 python-websockets/websockets#16
As of CPython 3.6.1, drain() is not coroutine-safe so put a lock around it to make sure it only ever gets called from a single coroutine at a time. http://bugs.python.org/issue29930 python-websockets/websockets#16
As of CPython 3.6.1, drain() is not coroutine-safe so put a lock around it to make sure it only ever gets called from a single coroutine at a time. http://bugs.python.org/issue29930 python-websockets/websockets#16
I'm constantly getting the following exception:
What would be the reason?
The text was updated successfully, but these errors were encountered: