Browse Source

fixup #15353 - Sleep when transmitting bytes temporarily fails

When we fail to send bytes, sleep for 1 second before retrying.
This avoids trying a few thousand times a second.
teor (Tim Wilson-Brown) 8 years ago
parent
commit
42e7bd4c53
1 changed files with 3 additions and 1 deletions
  1. 3 1
      lib/chutney/Traffic.py

+ 3 - 1
lib/chutney/Traffic.py

@@ -27,6 +27,7 @@ import socket
 import select
 import struct
 import errno
+import time
 
 # Set debug_flag=True in order to debug this program or to get hints
 # about what's going wrong in your system.
@@ -291,9 +292,10 @@ class Source(Peer):
         else:
           debug("BUG: sent no bytes")
           self._sent_no_bytes += 1
-          if self._sent_no_bytes >= 10000:
+          if self._sent_no_bytes >= 10:
             print("Send no data %d times. Stalled." % (self._sent_no_bytes))
             sys.exit(-1)
+          time.sleep(1)
         self.outbuf = self.outbuf[n:]
         if self.state == self.CONNECTING_THROUGH_PROXY:
             return 1            # Keep us around.