Skip to content

Commit 60c8d88

Browse files
committed
dont retrieve all jobs to be requeued
1 parent 39769d2 commit 60c8d88

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

mrq/basetasks/utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,13 @@ def perform_action(self, action, query, destination_queue):
123123

124124
# Requeue task by groups of maximum 1k items (if all in the same
125125
# queue)
126-
cursor = self.collection.find(query, projection=["_id", "queue"])
126+
status_query = query.get("status")
127+
if not status_query:
128+
query["status"] = {"$ne": "queued"}
127129

128-
# We must freeze the list because queries below would change it.
129-
# This could not fit in memory, research adding {"stats": {"$ne":
130-
# "queued"}} in the query
131-
fetched_jobs = list(cursor)
130+
cursor = self.collection.find(query, projection=["_id", "queue"])
132131

133-
for jobs in group_iter(fetched_jobs, n=1000):
132+
for jobs in group_iter(cursor, n=1000):
134133

135134
jobs_by_queue = defaultdict(list)
136135
for job in jobs:

0 commit comments

Comments
 (0)