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

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