Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
val500 committed Oct 15, 2024
1 parent ee9b974 commit 5e1ebd9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions server/src/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def pop_job(queue_list):
"""Get the next job in the queue"""
# The queue name and the job are returned, but we don't need the queue now
try:
response = mongo.db.jobs.find_one(
response = mongo.db.jobs.find_one_and_update(
{
"result_data.job_state": "waiting",
"job_data.job_queue": {"$in": queue_list},
Expand All @@ -186,6 +186,7 @@ def pop_job(queue_list):
{"job_data.attachments_status": "complete"},
],
},
{"$set": {"result_data.job_state": "running"}},
projection={
"job_id": True,
"created_at": True,
Expand All @@ -206,12 +207,7 @@ def pop_job(queue_list):
started_at = datetime.now(timezone.utc)
mongo.db.jobs.update_one(
{"job_id": job_id},
{
"$set": {
"started_at": started_at,
"result_data.job_state": "running",
}
},
{"$set": {"started_at": started_at}},
)
# Save data about the wait time in the queue
created_at = response["created_at"]
Expand Down

0 comments on commit 5e1ebd9

Please sign in to comment.