Blame 00181-allow-arbitrary-timeout-in-condition-wait.patch

383dbe3
diff --git a/Lib/threading.py b/Lib/threading.py
383dbe3
index cb49c4a..c9795a5 100644
383dbe3
--- a/Lib/threading.py
383dbe3
+++ b/Lib/threading.py
383dbe3
@@ -305,7 +305,7 @@ class _Condition(_Verbose):
383dbe3
         else:
383dbe3
             return True
383dbe3
 
383dbe3
-    def wait(self, timeout=None):
383dbe3
+    def wait(self, timeout=None, balancing=True):
383dbe3
         """Wait until notified or until a timeout occurs.
383dbe3
 
383dbe3
         If the calling thread has not acquired the lock when this method is
383dbe3
@@ -354,7 +354,10 @@ class _Condition(_Verbose):
383dbe3
                     remaining = endtime - _time()
383dbe3
                     if remaining <= 0:
383dbe3
                         break
383dbe3
-                    delay = min(delay * 2, remaining, .05)
383dbe3
+                    if balancing:
383dbe3
+                        delay = min(delay * 2, remaining, 0.05)
383dbe3
+                    else:
383dbe3
+                        delay = remaining
383dbe3
                     _sleep(delay)
383dbe3
                 if not gotit:
383dbe3
                     if __debug__:
383dbe3
@@ -599,7 +602,7 @@ class _Event(_Verbose):
383dbe3
         finally:
383dbe3
             self.__cond.release()
383dbe3
 
383dbe3
-    def wait(self, timeout=None):
383dbe3
+    def wait(self, timeout=None, balancing=True):
383dbe3
         """Block until the internal flag is true.
383dbe3
 
383dbe3
         If the internal flag is true on entry, return immediately. Otherwise,
383dbe3
@@ -617,7 +620,7 @@ class _Event(_Verbose):
383dbe3
         self.__cond.acquire()
383dbe3
         try:
383dbe3
             if not self.__flag:
383dbe3
-                self.__cond.wait(timeout)
383dbe3
+                self.__cond.wait(timeout, balancing)
383dbe3
             return self.__flag
383dbe3
         finally:
383dbe3
             self.__cond.release()
383dbe3
@@ -908,7 +911,7 @@ class Thread(_Verbose):
383dbe3
             if 'dummy_threading' not in _sys.modules:
383dbe3
                 raise
383dbe3
 
383dbe3
-    def join(self, timeout=None):
383dbe3
+    def join(self, timeout=None, balancing=True):
383dbe3
         """Wait until the thread terminates.
383dbe3
 
383dbe3
         This blocks the calling thread until the thread whose join() method is
383dbe3
@@ -957,7 +960,7 @@ class Thread(_Verbose):
383dbe3
                         if __debug__:
383dbe3
                             self._note("%s.join(): timed out", self)
383dbe3
                         break
383dbe3
-                    self.__block.wait(delay)
383dbe3
+                    self.__block.wait(delay, balancing)
383dbe3
                 else:
383dbe3
                     if __debug__:
383dbe3
                         self._note("%s.join(): thread stopped", self)
383dbe3
@@ -1143,7 +1146,7 @@ class _DummyThread(Thread):
383dbe3
     def _set_daemon(self):
383dbe3
         return True
383dbe3
 
383dbe3
-    def join(self, timeout=None):
383dbe3
+    def join(self, timeout=None, balancing=True):
383dbe3
         assert False, "cannot join a dummy thread"
383dbe3
 
383dbe3