-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
given the current definition of _read_until(), if recv() reads multiple occurrences of the frame-ending delimiter, only the content of the frame ending at the first delimiter is handled right away (by calback())... the remaining content will only be handled the next time _read_until() is triggered (e.g., by an incoming socket message or heartbeat)... so you basically get sort of a lag situation where new messages only get handled when newer ones come in...
my _read_until() addresses this... it also includes the fix from https://github.com/mtah/python-websocket/issues/1
def _read_until(self, delimiter, callback):
def lookForAndHandleCompletedFrame():
pos = self._read_buffer.find(delimiter)
if pos >= 0:
pos += len(delimiter)
data = self._read_buffer[:pos]
self._read_buffer = self._read_buffer[pos:]
if data:
callback(data)
lookForAndHandleCompletedFrame()
self._read_buffer += self.recv(4096)
lookForAndHandleCompletedFrame()
enjoy!
Metadata
Metadata
Assignees
Labels
No labels