zeekay/flask-uwsgi-websocket — pull request #10 by matthewowen (2014-11-11 19:56:55+00:00)
Title: Prevents `GeventWebSocketClient.send` from blocking on full queues.

If one wishes to have a process which stores references to a number of connections, and then sends out messages to them based on events, then the maximum queue length is problematic, since it means that if any messages have not been sent for a particular connection, then any future send calls to that connection will block until the first message has been sent.

Concretely, the big issue that we've seen is that it is possible that between calling `send` and the message actually being sent, the connection can be dropped. If two calls are made to send in this period of time the second call will hang forever (even with a check that `connected` is True).

In the current implementation, there's no guarantee of when a call to `send` will actually result in sending the message to the client. As a consequence, there doesn't seem to be any benefit to blocking subsequent calls (since we're using a Queue, message order will be preserved in any case).