Author xiaowen
Recipients
Date 2007-03-29.01:41:49
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Patch implementing what jtate described:

--- python/Lib/threading.py     2007-03-29 09:13:53.000000000 +0800
+++ python/Lib/threading.py.new 2007-03-29 09:26:44.000000000 +0800
@@ -222,15 +222,19 @@
                 # than 20 times per second (or the timeout time remaining).
                 endtime = _time() + timeout
                 delay = 0.0005 # 500 us -> initial delay of 1 ms
+                remaining = max(timeout, 0)
                 while True:
                     gotit = waiter.acquire(0)
                     if gotit:
                         break
-                    remaining = endtime - _time()
                     if remaining <= 0:
                         break
                     delay = min(delay * 2, remaining, .05)
                     _sleep(delay)
+                    if endtime - _time() > remaining:
+                        # Time must have been moved back, so readjust endtime.
+                        endtime = _time() + remaining - delay
+                    remaining = endtime - _time()
                 if not gotit:
                     if __debug__:
                         self._note("%s.wait(%s): timed out", self, timeout)
--- python/Lib/Queue.py         2007-01-01 00:38:56.000000000 +0800
+++ python/Lib/Queue.py.new     2007-01-01 00:42:14.000000000 +0800
@@ -127,7 +127,7 @@
                 endtime = _time() + timeout
                 while self._full():
                     remaining = endtime - _time()
-                    if remaining <= 0.0:
+                    if remaining <= 0.0 or remaining > timeout:
                         raise Full
                     self.not_full.wait(remaining)
             self._put(item)
@@ -169,7 +169,7 @@
                 endtime = _time() + timeout
                 while self._empty():
                     remaining = endtime - _time()
-                    if remaining <= 0.0:
+                    if remaining <= 0.0 or remaining > timeout:
                         raise Empty
                     self.not_empty.wait(remaining)
             item = self._get()
History
Date User Action Args
2007-08-23 14:40:43adminlinkissue1508864 messages
2007-08-23 14:40:43admincreate