Skip to content

Commit e57fdc1

Browse files
committed
fixing synthax and format
1 parent 1d4cd6c commit e57fdc1

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

src/apps/competitions/tasks.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from asgiref.sync import async_to_sync
4444

4545
import logging
46+
4647
logger = logging.getLogger(__name__)
4748

4849
r = get_redis_connection("default")
@@ -940,9 +941,8 @@ def refresh_compute_worker_health():
940941
if not is_compute_worker:
941942
continue
942943

943-
running_jobs = (
944-
len(active.get(worker_name, []))
945-
+ len(reserved.get(worker_name, []))
944+
running_jobs = len(active.get(worker_name, [])) + len(
945+
reserved.get(worker_name, [])
946946
)
947947
status = "busy" if running_jobs > 0 else "available"
948948

@@ -964,15 +964,17 @@ def refresh_compute_worker_health():
964964
r.hset(
965965
WORKERS_REGISTRY_KEY,
966966
worker_name,
967-
json.dumps({
968-
"hostname": worker_name,
969-
"status": status,
970-
"running_jobs": running_jobs,
971-
"last_seen": payload["timestamp"],
972-
}),
967+
json.dumps(
968+
{
969+
"hostname": worker_name,
970+
"status": status,
971+
"running_jobs": running_jobs,
972+
"last_seen": payload["timestamp"],
973+
}
974+
),
973975
)
974976

975977
_broadcast_worker_state(payload)
976978
logger.info(
977979
f"[WORKER-HEALTH] {worker_name} status={status} jobs={running_jobs}"
978-
)
980+
)

src/celery_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ def app_for_vhost(vhost):
4242
_vhost_apps[vhost] = vhost_app
4343
return _vhost_apps[vhost]
4444

45+
4546
app.conf.beat_schedule = {
4647
"refresh-compute-worker-health": {
4748
"task": "apps.competitions.tasks.refresh_compute_worker_health",
4849
"schedule": 3.0,
4950
},
50-
}
51+
}

src/utils/consumers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ def _load_snapshot(self):
7979
if not is_compute_worker:
8080
continue
8181

82-
running_jobs = (
83-
len(active.get(worker_name, []))
84-
+ len(reserved.get(worker_name, []))
82+
running_jobs = len(active.get(worker_name, [])) + len(
83+
reserved.get(worker_name, [])
8584
)
8685
status = "busy" if running_jobs > 0 else "available"
8786

@@ -94,4 +93,4 @@ def _load_snapshot(self):
9493
}
9594
)
9695

97-
return workers
96+
return workers

0 commit comments

Comments
 (0)