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

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