Skip to content

Commit

Permalink
Fix bytes_sent accounting in makefile's write
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Oct 22, 2018
1 parent 406dc18 commit 807aebe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cheroot/makefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ def _drop(self):

def write(self, data):
"""Sendall for non-blocking sockets."""
bytes_sent = 0
data_mv = memoryview(data)
payload_size = len(data_mv)
while self.bytes_written <= payload_size:
while bytes_sent < payload_size:
try:
self.send(data_mv[self.bytes_written:])
bytes_sent += self.send(data_mv[bytes_sent:])
except socket.error as e:
if e.args[0] not in errors.socket_errors_nonblocking:
raise
Expand Down

0 comments on commit 807aebe

Please sign in to comment.