forked from mtusi2026/mtusi2026lab5
level 4
This commit is contained in:
@@ -102,6 +102,38 @@ def worker_concurrency() -> int:
|
||||
return _bounded_int('WORKER_CONCURRENCY', 1, 8)
|
||||
|
||||
|
||||
def _bounded_float(name: str, default: float, upper: float) -> float:
|
||||
raw = os.getenv(name, '').strip()
|
||||
try:
|
||||
value = float(raw) if raw else default
|
||||
except ValueError:
|
||||
raise RuntimeError('%s must be a number' % name) from None
|
||||
if value <= 0 or value > upper:
|
||||
raise RuntimeError('%s must be greater than 0 and at most %s' % (name, upper))
|
||||
return value
|
||||
|
||||
|
||||
def retry_base_seconds() -> float:
|
||||
return _bounded_float('JOB_RETRY_BASE_SECONDS', 0.5, 60)
|
||||
|
||||
|
||||
def retry_cap_seconds() -> float:
|
||||
return _bounded_float('JOB_RETRY_CAP_SECONDS', 30, 600)
|
||||
|
||||
|
||||
def job_lease_seconds() -> int:
|
||||
return _bounded_int('JOB_LEASE_SECONDS', 90, 3600)
|
||||
|
||||
|
||||
def effective_lease_seconds() -> int:
|
||||
"""A live attempt refreshes this. It stays longer than the processing timeout."""
|
||||
return max(job_lease_seconds(), job_timeout_seconds() + 30)
|
||||
|
||||
|
||||
def staging_retention_seconds() -> int:
|
||||
return _bounded_int('STAGING_RETENTION_SECONDS', 86400, 86400 * 30)
|
||||
|
||||
|
||||
def load_object_settings() -> ObjectSettings:
|
||||
"""S3 credentials come from files. The values are not logged."""
|
||||
endpoint = os.getenv('S3_ENDPOINT', '').strip()
|
||||
|
||||
Reference in New Issue
Block a user