Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed acquire_jobs method in MongoDB DataStore. #948

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ docs/_build/
build/
virtualenv/
venv*/
env*/
HK-Mattew marked this conversation as resolved.
Show resolved Hide resolved
example.sqlite
6 changes: 5 additions & 1 deletion src/apscheduler/datastores/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,9 @@ async def acquire_jobs(
)
async for doc in cursor:
task_max_running_jobs = doc["max_running_jobs"]
task_job_slots_left[doc["_id"]] = doc["max_running_jobs"]
task_job_slots_left[doc["_id"]] = (
doc["max_running_jobs"] - doc["running_jobs"]
)

acquired_jobs: list[Job] = []
skipped_job_ids: list[UUID] = []
Expand Down Expand Up @@ -688,6 +690,8 @@ async def acquire_jobs(
self._logger.debug(
"Skipping job %s because task %r has the maximum "
"number of %d jobs already running",
job,
job.task_id,
task_max_running_jobs,
)
skipped_job_ids.append(job.id)
Expand Down
Loading