mongoqueue
mongoqueue copied to clipboard
repair only affects one job
The use of find_and_modify
means only one Job is recovered from stale lock.
The same query + update expressions work with the PyMongo function update_many
which updates all documents that match.
it = q.collection.update_many({"locked_by": {"$ne": None}, "locked_at": { "$lt": datetime.now() - timedelta(0.125)}},{"$set": {"locked_by": None, "locked_at": None},"$inc": {"attempts": 1}})