From 630159768d3fb278992e085c1ca46acae1644360 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 12 Feb 2020 16:53:52 -0800 Subject: [PATCH] Use slice assignment instead of list.remove for clearing jobs. --- voussoirkit/threadpool.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/voussoirkit/threadpool.py b/voussoirkit/threadpool.py index 788782b..31e007b 100644 --- a/voussoirkit/threadpool.py +++ b/voussoirkit/threadpool.py @@ -32,10 +32,7 @@ class ThreadPool: This function assumes that job_manager_lock is acquired!! You should call clear_done_and_start_jobs instead! ''' - for job in list(self.jobs): - if job.status in {FINISHED, RAISED}: - # print('Removing done job', job) - self.jobs.remove(job) + self.jobs[:] = [j for j in self.jobs if j.status in {PENDING, RUNNING}] def _start_jobs(self): '''