Skip to content

Commit 3ae5d79

Browse files
authored
Skip dispatching extend_acquired_job_leases with no jobs (#1031)
1 parent ab5395d commit 3ae5d79

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

docs/versionhistory.rst

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ APScheduler, see the :doc:`migration section <migration>`.
6464
schema if it's missing (PR by @zhu0629)
6565
- Fixed an issue with ``CronTrigger`` infinitely looping to get next date when DST ends
6666
(`#980 <https://github.com/agronholm/apscheduler/issues/980>`_; PR by @hlobit)
67+
- Skip dispatching extend_acquired_job_leases with no jobs (PR by @JacobHayes)
6768

6869
**4.0.0a5**
6970

src/apscheduler/_schedulers/async_.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,10 @@ async def check_queue_capacity(event: Event) -> None:
11081108
async def extend_job_leases() -> None:
11091109
while self._state is RunState.started:
11101110
await sleep(self.lease_duration.total_seconds() / 2)
1111-
job_ids = {job.id for job in self._running_jobs}
1112-
await self.data_store.extend_acquired_job_leases(
1113-
self.identity, job_ids, self.lease_duration
1114-
)
1111+
if job_ids := {job.id for job in self._running_jobs}:
1112+
await self.data_store.extend_acquired_job_leases(
1113+
self.identity, job_ids, self.lease_duration
1114+
)
11151115

11161116
async with AsyncExitStack() as exit_stack:
11171117
# Start the job executors

0 commit comments

Comments
 (0)