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

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