Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent iterable changing size during iteration. #8133

Merged
merged 1 commit into from
Jun 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion kolibri/core/tasks/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def __init__(self, queues, connection=None, num_workers=3):

def shutdown_workers(self, wait=True):
# First cancel all running jobs
job_ids = self.future_job_mapping.keys()
# Coerce to a list, as otherwise the iterable can change size
# during iteration, as jobs are cancelled and removed from the mapping
job_ids = list(self.future_job_mapping.keys())
for job_id in job_ids:
logger.info("Canceling job id {}.".format(job_id))
self.cancel(job_id)
Expand Down