commit 42e7bd4c53e3a84ddae3d5900017753b32e998df Author: teor (Tim Wilson-Brown) teor2345@gmail.com Date: Fri Oct 9 06:25:01 2015 +1100
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. --- lib/chutney/Traffic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/chutney/Traffic.py b/lib/chutney/Traffic.py index 76f16e4..7d61759 100644 --- a/lib/chutney/Traffic.py +++ b/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.