Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Websocket hangs with Windows and Python 3.8 #31

Closed
jyu00 opened this issue Jul 8, 2020 · 5 comments
Closed

Websocket hangs with Windows and Python 3.8 #31

jyu00 opened this issue Jul 8, 2020 · 5 comments

Comments

@jyu00
Copy link

jyu00 commented Jul 8, 2020

Connection 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.

@erdewit
Copy link
Owner

erdewit commented Jul 15, 2020

In the script to reproduce the issue it seems that the definition for job_status is omitted.

@jyu00
Copy link
Author

jyu00 commented Jul 16, 2020

Yeah sorry the simplified version should not have job_status. Updated the original text.

@WestXu
Copy link

WestXu commented Aug 11, 2020

pip install nest_asyncio==1.3.3 fixes it.

@erdewit
Copy link
Owner

erdewit commented Oct 25, 2020

I can reproduce the issue on Windows 10, Python 3.9. The issue is the ProactorEvenLloop getting a timeout of None in a select call, which then leaves it hanging. A work-around has been added to use a definite timeout value instead of None.

@erdewit
Copy link
Owner

erdewit commented Oct 25, 2020

This is released now in v1.4.2.

@erdewit erdewit closed this as completed Oct 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants