Revision d385a174 lib/mcpu.py
b/lib/mcpu.py | ||
---|---|---|
55 | 55 |
"""Calculate timeouts for lock attempts. |
56 | 56 |
|
57 | 57 |
""" |
58 |
result = [1.0] |
|
58 |
result = [constants.LOCK_ATTEMPTS_MINWAIT] |
|
59 |
running_sum = result[0] |
|
59 | 60 |
|
60 |
# Wait for a total of at least 150s before doing a blocking acquire |
|
61 |
while sum(result) < 150.0: |
|
61 |
# Wait for a total of at least LOCK_ATTEMPTS_TIMEOUT before doing a |
|
62 |
# blocking acquire |
|
63 |
while running_sum < constants.LOCK_ATTEMPTS_TIMEOUT: |
|
62 | 64 |
timeout = (result[-1] * 1.05) ** 1.25 |
63 | 65 |
|
64 |
# Cap timeout at 10 seconds. This gives other jobs a chance to run |
|
65 |
# even if we're still trying to get our locks, before finally moving |
|
66 |
# to a blocking acquire. |
|
67 |
if timeout > 10.0: |
|
68 |
timeout = 10.0 |
|
69 |
|
|
70 |
elif timeout < 0.1: |
|
71 |
# Lower boundary for safety |
|
72 |
timeout = 0.1 |
|
66 |
# Cap max timeout. This gives other jobs a chance to run even if |
|
67 |
# we're still trying to get our locks, before finally moving to a |
|
68 |
# blocking acquire. |
|
69 |
timeout = min(timeout, constants.LOCK_ATTEMPTS_MAXWAIT) |
|
70 |
# And also cap the lower boundary for safety |
|
71 |
timeout = max(timeout, constants.LOCK_ATTEMPTS_MINWAIT) |
|
73 | 72 |
|
74 | 73 |
result.append(timeout) |
74 |
running_sum += timeout |
|
75 | 75 |
|
76 | 76 |
return result |
77 | 77 |
|
Also available in: Unified diff