Revision 6b27f535 lib/masterd/instance.py
b/lib/masterd/instance.py | ||
---|---|---|
130 | 130 |
""" |
131 | 131 |
|
132 | 132 |
|
133 |
def _TimeoutExpired(epoch, timeout, _time_fn=time.time): |
|
134 |
"""Checks whether a timeout has expired. |
|
135 |
|
|
136 |
""" |
|
137 |
return _time_fn() > (epoch + timeout) |
|
138 |
|
|
139 |
|
|
140 | 133 |
class _DiskImportExportBase(object): |
141 | 134 |
MODE_TEXT = None |
142 | 135 |
|
... | ... | |
319 | 312 |
assert self._ts_begin is not None |
320 | 313 |
|
321 | 314 |
if not data: |
322 |
if _TimeoutExpired(self._ts_begin, self._timeouts.ready):
|
|
315 |
if utils.TimeoutExpired(self._ts_begin, self._timeouts.ready):
|
|
323 | 316 |
raise _ImportExportError("Didn't become ready after %s seconds" % |
324 | 317 |
self._timeouts.ready) |
325 | 318 |
|
... | ... | |
342 | 335 |
if self._ts_last_error is None: |
343 | 336 |
self._ts_last_error = time.time() |
344 | 337 |
|
345 |
elif _TimeoutExpired(self._ts_last_error, self._timeouts.error):
|
|
338 |
elif utils.TimeoutExpired(self._ts_last_error, self._timeouts.error):
|
|
346 | 339 |
raise _ImportExportError("Too many errors while updating data") |
347 | 340 |
|
348 | 341 |
return False |
... | ... | |
386 | 379 |
|
387 | 380 |
return True |
388 | 381 |
|
389 |
if _TimeoutExpired(self._GetConnectedCheckEpoch(), self._timeouts.connect): |
|
382 |
if utils.TimeoutExpired(self._GetConnectedCheckEpoch(), |
|
383 |
self._timeouts.connect): |
|
390 | 384 |
raise _ImportExportError("Not connected after %s seconds" % |
391 | 385 |
self._timeouts.connect) |
392 | 386 |
|
... | ... | |
397 | 391 |
|
398 | 392 |
""" |
399 | 393 |
if ((self._ts_last_progress is None or |
400 |
_TimeoutExpired(self._ts_last_progress, self._timeouts.progress)) and |
|
394 |
utils.TimeoutExpired(self._ts_last_progress, |
|
395 |
self._timeouts.progress)) and |
|
401 | 396 |
self._daemon and |
402 | 397 |
self._daemon.progress_mbytes is not None and |
403 | 398 |
self._daemon.progress_throughput is not None): |
... | ... | |
560 | 555 |
|
561 | 556 |
return True |
562 | 557 |
|
563 |
if _TimeoutExpired(self._ts_begin, self._timeouts.listen):
|
|
558 |
if utils.TimeoutExpired(self._ts_begin, self._timeouts.listen):
|
|
564 | 559 |
raise _ImportExportError("Not listening after %s seconds" % |
565 | 560 |
self._timeouts.listen) |
566 | 561 |
|
Also available in: Unified diff