]>
Commit | Line | Data |
---|---|---|
48d9a6a0 MT |
1 | diff --git a/Lib/threading.py b/Lib/threading.py |
2 | index cb49c4a..c9795a5 100644 | |
3 | --- a/Lib/threading.py | |
4 | +++ b/Lib/threading.py | |
5 | @@ -305,7 +305,7 @@ class _Condition(_Verbose): | |
6 | else: | |
7 | return True | |
8 | ||
9 | - def wait(self, timeout=None): | |
10 | + def wait(self, timeout=None, balancing=True): | |
11 | """Wait until notified or until a timeout occurs. | |
12 | ||
13 | If the calling thread has not acquired the lock when this method is | |
14 | @@ -354,7 +354,10 @@ class _Condition(_Verbose): | |
15 | remaining = endtime - _time() | |
16 | if remaining <= 0: | |
17 | break | |
18 | - delay = min(delay * 2, remaining, .05) | |
19 | + if balancing: | |
20 | + delay = min(delay * 2, remaining, 0.05) | |
21 | + else: | |
22 | + delay = remaining | |
23 | _sleep(delay) | |
24 | if not gotit: | |
25 | if __debug__: | |
26 | @@ -599,7 +602,7 @@ class _Event(_Verbose): | |
27 | finally: | |
28 | self.__cond.release() | |
29 | ||
30 | - def wait(self, timeout=None): | |
31 | + def wait(self, timeout=None, balancing=True): | |
32 | """Block until the internal flag is true. | |
33 | ||
34 | If the internal flag is true on entry, return immediately. Otherwise, | |
35 | @@ -617,7 +620,7 @@ class _Event(_Verbose): | |
36 | self.__cond.acquire() | |
37 | try: | |
38 | if not self.__flag: | |
39 | - self.__cond.wait(timeout) | |
40 | + self.__cond.wait(timeout, balancing) | |
41 | return self.__flag | |
42 | finally: | |
43 | self.__cond.release() | |
44 | @@ -908,7 +911,7 @@ class Thread(_Verbose): | |
45 | if 'dummy_threading' not in _sys.modules: | |
46 | raise | |
47 | ||
48 | - def join(self, timeout=None): | |
49 | + def join(self, timeout=None, balancing=True): | |
50 | """Wait until the thread terminates. | |
51 | ||
52 | This blocks the calling thread until the thread whose join() method is | |
53 | @@ -957,7 +960,7 @@ class Thread(_Verbose): | |
54 | if __debug__: | |
55 | self._note("%s.join(): timed out", self) | |
56 | break | |
57 | - self.__block.wait(delay) | |
58 | + self.__block.wait(delay, balancing) | |
59 | else: | |
60 | if __debug__: | |
61 | self._note("%s.join(): thread stopped", self) | |
62 | @@ -1143,7 +1146,7 @@ class _DummyThread(Thread): | |
63 | def _set_daemon(self): | |
64 | return True | |
65 | ||
66 | - def join(self, timeout=None): | |
67 | + def join(self, timeout=None, balancing=True): | |
68 | assert False, "cannot join a dummy thread" | |
69 | ||
70 |