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

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