python-sonic-client
python-sonic-client copied to clipboard
Large PUSH content crash the client
Describe the bug When the pushed text is large, the client throw weird error.
To Reproduce push few k of text.
Expected behavior The command should use splitted content, like : https://github.com/valeriansaliou/node-sonic-channel/blob/master/lib/channel/generic.js#L328
usually, we do
def _chunks(self, txt, length):
if not txt:
return None
for i in range(0, len(txt), length):
if i + length > len(txt):
yield txt[i:]
else:
yield txt[i : i + length]
for chunk in self._chunks(text, int(self.sonic.bufsize) // 2):
self.sonic.push(bucket, collection, object_tag, chunk)
probably not the most efficient, maybe add param chunk=True to enable that call.
It's in the protocol, it crashs when you push large stuff without it, why doesn't use it in this library?
Your split with range is far less ugly than my while loop with reassignation.