Websocket hangs with Windows and Python 3.8
See original GitHub issueConnection via websockets
hangs when running on Windows with Python 3.8, nest_asyncio
, and the default WindowsProactorEventLoopPolicy
. A simple program can reproduce this:
import asyncio
import nest_asyncio
from websockets import connect
nest_asyncio.apply()
async def _connect():
websocket = await connect('wss://wss.foo.com:9876')
def client():
loop = asyncio.get_event_loop()
return loop.run_until_complete(_connect())
if __name__ == "__main__":
client()
This works on other platforms/Python versions/policy, or without nest_asyncio
. I did a little bit of tracing, and it looks like the connect()
completed successfully, but it somehow got stuck when selecting the next event.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
python - Websocket freezes program if no clients are connected
The problem is that when no client is connected, program freezes, missing events from translation which runs in real time. How can I...
Read more >websocket-client - PyPI
websocket -client is a WebSocket client for Python. It provides access to low level APIs for WebSockets. websocket-client implements version hybi-13 of the ......
Read more >Socket Timeout — An Important and Sometimes Complicated ...
During my experience working with Python, I've had several cases where a network client was left hanging while trying to request a server....
Read more >Changelog — Python 3.11.1 documentation
gh-89237: Fix hang on Windows in subprocess.wait_closed() in asyncio with ... process user as was the default in Python 3.8 and earlier.
Read more >python-websockets(1) - Arch manual pages
#!/usr/bin/env python import asyncio import websockets async def echo(websocket): ... We're using window.alert() for simplicity in this tutorial.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is released now in v1.4.2.
pip install nest_asyncio==1.3.3
fixes it.