Commits

Denis Bilenko committed 9946460

Fix issue #150: Do not wait for write event in gevent.fileobject.SocketAdapter.sendall() if everything was written already. Based on patch by Mark Hingston.

Comments (0)

Files changed (1)

gevent/fileobject.py

             fileno = self.fileno()
             bytes_total = len(data)
             bytes_written = 0
-            while bytes_written < bytes_total:
+            while True:
                 try:
                     bytes_written += _write(fileno, _get_memory(data, bytes_written))
                 except (IOError, OSError):
                     if code not in ignored_errors:
                         raise
                     sys.exc_clear()
+                if bytes_written >= bytes_total:
+                    return
                 self.hub.wait(self._write_event)
 
         def recv(self, size):