Skip to content

Commit 69bed37

Browse files
committed
fix(collector): reduce critical section duration
By copying the deployment dict the lock is released sooner while still allowing the watcher to process events without interfering with the collector run.
1 parent df4f9c8 commit 69bed37

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

schedule_scaling/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,11 @@ def collect_scaling_jobs(cls, ds: DeploymentStore, queue: Queue) -> None:
300300

301301
while not shutdown:
302302
with ds.lock:
303-
for deployment, schedule_action in ds.deployments.items():
304-
process_deployment(deployment, schedule_action, queue)
303+
# work on a copy so that we can release the lock sooner
304+
deployments = ds.deployments.copy()
305+
306+
for deployment, schedule_action in deployments.items():
307+
process_deployment(deployment, schedule_action, queue)
305308
logging.debug(f"queue items: {list(queue.queue)}")
306309
# wait until next minute but wake up if you have to shutdown
307310
with cls.condition:

0 commit comments

Comments
 (0)