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

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