Rev 6145: Don't traceback for timeouts, and give better documentation about why we don't just select. in http://bazaar.launchpad.net/~jameinel/bzr/drop-idle-connections-824797

John Arbash Meinel john at arbash-meinel.com
Wed Sep 14 13:47:15 UTC 2011


At http://bazaar.launchpad.net/~jameinel/bzr/drop-idle-connections-824797

------------------------------------------------------------
revno: 6145
revision-id: john at arbash-meinel.com-20110914134707-sx18ml5ey5o3wv38
parent: john at arbash-meinel.com-20110914125817-h9csfegz6bvz93yj
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: drop-idle-connections-824797
timestamp: Wed 2011-09-14 15:47:07 +0200
message:
  Don't traceback for timeouts, and give better documentation about why we don't just select.
-------------- next part --------------
=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py	2011-09-14 12:58:17 +0000
+++ b/bzrlib/smart/medium.py	2011-09-14 13:47:07 +0000
@@ -231,8 +231,10 @@
                 self._serve_one_request(server_protocol)
         except errors.ConnectionTimeout, e:
             trace.note('%s' % (e,))
+            trace.log_exception_quietly()
             self._close()
-            raise
+            # We reported it, no reason to make a big fuss.
+            return
         except Exception, e:
             stderr.write("%s terminating on exception %s\n" % (self, e))
             raise
@@ -288,11 +290,15 @@
                 or timeout_seconds <= self._stream_medium_fast_timeout):
                 rs, _, _ = select.select([fd], [], [], timeout_seconds)
             else:
-                # For some reason select.select() during the test suite may
-                # sometimes pause until timeout triggers. However, if we call
-                # it again, it correctly determines that rs is no longer
-                # blocking. So we set a short select() timeout, but pause
-                # overall until the timeout finishes
+                # It looks like during the test suite, we close the server-side
+                # socket as part of 'shut down this server'. Depending on how
+                # we race with select.select, that either
+                # 1) Raises socket.error(EBADF) immediately
+                # 2) Occasionally (1 in 1000 or so) raises select.error(EBADF)
+                # 3) 1-in-3 or so times out, calling select.select immediately
+                #    afterwards seems to raise EBADF.
+                # I think what happens is select.select is unable to see the
+                # status of a file that is closed after it starts 'sleeping'.
                 t_end = time.time() + timeout_seconds
                 rs = []
                 while not rs and time.time() < t_end:



More information about the bazaar-commits mailing list