diff --git a/.gitignore b/.gitignore index cc770a8f..7583132c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ docs/_build/ build/ virtualenv/ venv*/ +env*/ example.sqlite diff --git a/src/apscheduler/datastores/mongodb.py b/src/apscheduler/datastores/mongodb.py index 44e2b901..2aea594c 100644 --- a/src/apscheduler/datastores/mongodb.py +++ b/src/apscheduler/datastores/mongodb.py @@ -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] = [] @@ -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)