Clarify that WebSocket.{recv,recvmsg} may return empty messages

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2017-11-13 04:12:22 -05:00
parent a29946e978
commit b0df514344
1 changed files with 10 additions and 8 deletions

View File

@ -342,10 +342,11 @@ class WebSocket(object):
def recv(self):
"""Read data from the WebSocket.
This will return any available data on the socket. If the
socket is closed then None will be returned. The reason for
the close is found in the 'close_code' and 'close_reason'
properties.
This will return any available data on the socket (which may
be the empty string if the peer sent an empty message or
messages). If the socket is closed then None will be
returned. The reason for the close is found in the
'close_code' and 'close_reason' properties.
Unlike recvmsg() this method may return data from more than one
WebSocket message. It is however not guaranteed to return all
@ -360,10 +361,11 @@ class WebSocket(object):
def recvmsg(self):
"""Read a single message from the WebSocket.
This will return a single WebSocket message from the socket.
If the socket is closed then None will be returned. The
reason for the close is found in the 'close_code' and
'close_reason' properties.
This will return a single WebSocket message from the socket
(which will be the empty string if the peer sent an empty
message). If the socket is closed then None will be
returned. The reason for the close is found in the
'close_code' and 'close_reason' properties.
Unlike recv() this method will not return data from more than
one WebSocket message. Callers should continue calling