-
-
Notifications
You must be signed in to change notification settings - Fork 543
connection keepalive is not really async #872
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
Comments
No, a callback-based API wouldn't feel native in asyncio. You're doing something that blocks the event loop, but I cannot understand why with the limited amount of details you provided. https://github.com/aaugustin/websockets/blob/master/example/show_time.py is an example of a server that does exactly what you say and doesn't block the event loop. You can connect at least 10k clients to this server. |
Also, unfortunately, the issue you're linking to was a hodgepodge of unrelated tickets. It's more likely to create confusion than clarity. |
So this is a non-blocking call?
|
It's not blocking. |
You can also use: async for data in websocket:
... |
related #581
I've starting using this library and at the moment I have an endless loop in "async def client_connected(self, websocket, path): " to keep the connection alive.
However this is not a real soltion just a workaround to a problem, the moment you add endless loop the asyncio user is not able to use any other async tasks as this function will endlessly block the asyncio loop execution.
Wouldn't be a full asyncio solution to have a different API where functions are callbacks and first argument expresses what client triggered the event?
"client_connected(ws...)"
"data_received(ws, data)
"cliend_disconnected(ws, ...)"
...
etc
The text was updated successfully, but these errors were encountered: