Skip to content
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

Parallel chat message delivery should be preferred over sequential #4

Open
AlexKordic opened this issue Feb 19, 2021 · 1 comment
Open

Comments

@AlexKordic
Copy link

Hi,

Found your great tutorial article! Here is a comment in chat logic on line 27

    for _ws in self.request.app['websockets']:
        _ws.send_str('%s joined' % login)

I do wonder why await is not required for _ws.send_str() here?

Why don't we use asyncio.create_task(_ws.send_str()) ? My expectation is that without asyncio.create_task we are chaining send operations sequentially and if one of the browser's websockets is not reading (server's TCP socket's send buffer is full) chat logic will grind to halt. If we apply asyncio.create_task each send_str() call would be independent and can be stuck on send_str(), all pending send_str() calls would be cleaned when failed ping-pong of that websocket destroys connection.

Thanks for great article,
Alex

@AlexKordic
Copy link
Author

Hi,

Confirmed, without await the _ws.send_str('%s joined' % login) is noop statement, producing then discarding coroutine object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant