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

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