Don't check if item is in list

Just do set intersection. This is surprisingly something that takes up a
good amount of CPU time on job handlers if there are a lot of jobs.
With cumulative line-based profiling this is one of the top lines in
Galaxy code.
This commit is contained in:
mvdbeek
2021-02-03 11:54:19 +01:00
parent ccea6e3ad2
commit a72850ee75
+2 -3
View File
@@ -436,9 +436,8 @@ class JobHandlerQueue(Monitors):
if not self.track_jobs_in_database:
self.waiting_jobs = new_waiting_jobs
# Remove cached wrappers for any jobs that are no longer being tracked
for id in list(self.job_wrappers.keys()):
if id not in new_waiting_jobs:
del self.job_wrappers[id]
for id in set(self.job_wrappers.keys()) - set(new_waiting_jobs):
del self.job_wrappers[id]
# Flush, if we updated the state
self.sa_session.flush()
# Done with the session