Revision f4e673fb
b/lib/locking.py | ||
---|---|---|
134 | 134 |
@param timeout: Timeout for waiting (can be None) |
135 | 135 |
|
136 | 136 |
""" |
137 |
start_time = time.time() |
|
138 |
remaining_time = timeout |
|
137 |
running_timeout = RunningTimeout(timeout, True) |
|
138 |
|
|
139 |
while True: |
|
140 |
remaining_time = running_timeout.Remaining() |
|
141 |
|
|
142 |
if remaining_time is not None and remaining_time < 0.0: |
|
143 |
break |
|
139 | 144 |
|
140 |
while timeout is None or remaining_time > 0: |
|
141 | 145 |
try: |
142 | 146 |
result = self._poller.poll(remaining_time) |
143 | 147 |
except EnvironmentError, err: |
... | ... | |
149 | 153 |
if result and result[0][0] == self._fd: |
150 | 154 |
break |
151 | 155 |
|
152 |
# Re-calculate timeout if necessary |
|
153 |
if timeout is not None: |
|
154 |
remaining_time = start_time + timeout - time.time() |
|
155 |
|
|
156 | 156 |
|
157 | 157 |
class _BaseCondition(object): |
158 | 158 |
"""Base class containing common code for conditions. |
Also available in: Unified diff