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

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