Skip to content

Commit fd65998

Browse files
committed
session: Improve partial-buffer send algorithm
1 parent 6b66753 commit fd65998

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pynuodb/session.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,12 @@ def send(self, message):
470470
# don't have to reallocate this entire buffer, but it is unreliable.
471471
buf = lenbuf + data
472472
view = memoryview(buf)
473-
start = 0
474-
left = len(buf)
473+
end = len(buf)
474+
cur = 0
475475

476476
try:
477-
while left > 0:
478-
sent = sock.send(view[start:left])
479-
start += sent
480-
left -= sent
477+
while cur < end:
478+
cur += sock.send(view[cur:])
481479
except Exception:
482480
self.close()
483481
raise

0 commit comments

Comments
 (0)