Add default workers timeout to the server's configuration

This commit is contained in:
allegroai 2023-03-23 19:08:11 +02:00
parent 6664c6237e
commit cfbb37238f
3 changed files with 8 additions and 3 deletions

View File

@ -24,9 +24,7 @@ class WorkerRequest(Base):
class RegisterRequest(WorkerRequest): class RegisterRequest(WorkerRequest):
timeout = make_default( timeout = IntField(default=0) # registration timeout in seconds (if not specified, default is 10min)
IntField, DEFAULT_TIMEOUT
)() # registration timeout in seconds (default is 10min)
queues = ListField(six.string_types) # list of queues this worker listens to queues = ListField(six.string_types) # list of queues this worker listens to

View File

@ -113,6 +113,10 @@
# Timeout in seconds on task status update. If exceeded # Timeout in seconds on task status update. If exceeded
# then task can be stopped without communicating to the worker # then task can be stopped without communicating to the worker
task_update_timeout: 600 task_update_timeout: 600
# Timeout in seconds for worker registration (or status report). If a worker did not report for this long,
# it is discarded from the server's table
default_timeout: 600
} }
check_for_updates { check_for_updates {

View File

@ -56,6 +56,9 @@ def register(call: APICall, company_id, request: RegisterRequest):
timeout = request.timeout timeout = request.timeout
queues = request.queues queues = request.queues
if not timeout:
timeout = config.get("apiserver.workers.default_timeout", 10 * 60)
if not timeout or timeout <= 0: if not timeout or timeout <= 0:
raise bad_request.WorkerRegistrationFailed( raise bad_request.WorkerRegistrationFailed(
"invalid timeout", timeout=timeout, worker=worker "invalid timeout", timeout=timeout, worker=worker