Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,20 +732,23 @@ def pack_command(self, *args):
args = tuple(args[0].split()) + args[1:]

buff = SYM_EMPTY.join((SYM_STAR, str(len(args)).encode(), SYM_CRLF))

buffer_len = len(buff)
buffer_cutoff = self._buffer_cutoff

for arg in imap(self.encoder.encode, args):
# to avoid large string mallocs, chunk the command into the
# output list if we're sending large values
if len(buff) > buffer_cutoff or len(arg) > buffer_cutoff:

len_arg = len(arg)
if buffer_len > buffer_cutoff or len_arg > buffer_cutoff:
buff = SYM_EMPTY.join(
(buff, SYM_DOLLAR, str(len(arg)).encode(), SYM_CRLF))
(buff, SYM_DOLLAR, str(len_arg).encode(), SYM_CRLF))
output.append(buff)
output.append(arg)
buff = SYM_CRLF
else:
buff = SYM_EMPTY.join(
(buff, SYM_DOLLAR, str(len(arg)).encode(),
(buff, SYM_DOLLAR, str(len_arg).encode(),
SYM_CRLF, arg, SYM_CRLF))
output.append(buff)
return output
Expand Down