From 4c00dd3fbc3ac601440a5de2e0c9f9cae947ff43 Mon Sep 17 00:00:00 2001 From: "dashuai.wu" Date: Wed, 28 Nov 2018 20:24:21 +0800 Subject: [PATCH] fix bug:projects size changed while iterate --- pyspider/scheduler/scheduler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyspider/scheduler/scheduler.py b/pyspider/scheduler/scheduler.py index 084baff28..5c0359803 100644 --- a/pyspider/scheduler/scheduler.py +++ b/pyspider/scheduler/scheduler.py @@ -423,7 +423,7 @@ def _check_cronjob(self): if now - self._last_tick < 1: return False self._last_tick += 1 - for project in itervalues(self.projects): + for project in self.projects.values(): if not project.active: continue if project.waiting_get_info: @@ -481,7 +481,7 @@ def _check_select(self): # dynamic assign select limit for each project, use qsize as weight project_weights, total_weight = dict(), 0 - for project in itervalues(self.projects): # type:Project + for project in self.projects.values(): # type:Project if not project.active: continue # only check project pause when select new tasks, cronjob and new request still working @@ -630,7 +630,7 @@ def _try_dump_cnt(self): def _check_delete(self): '''Check project delete''' now = time.time() - for project in list(itervalues(self.projects)): + for project in self.projects.values(): if project.db_status != 'STOP': continue if now - project.updatetime < self.DELETE_TIME: