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

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