python-sonic-client icon indicating copy to clipboard operation
python-sonic-client copied to clipboard

Large PUSH content crash the client

Open athoune opened this issue 5 years ago • 2 comments

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

athoune avatar Jan 30 '20 19:01 athoune

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.

xmonader avatar Jan 30 '20 20:01 xmonader

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.

athoune avatar Jan 30 '20 20:01 athoune