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

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