Skip to content

Commit

Permalink
Calculate sleep time based on a recent call to datetime.now()
Browse files Browse the repository at this point in the history
Closes #754.
  • Loading branch information
agronholm committed Aug 12, 2023
1 parent 7a59acd commit fca40a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions apscheduler/schedulers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ def _process_jobs(self):
wait_seconds = None
self._logger.debug('No jobs; waiting until a job is added')
else:
now = datetime.now(self.timezone)
wait_seconds = min(max(timedelta_seconds(next_wakeup_time - now), 0), TIMEOUT_MAX)
self._logger.debug('Next wakeup is due at %s (in %f seconds)', next_wakeup_time,
wait_seconds)
Expand Down
2 changes: 2 additions & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ UNRELEASED
(PR by Ran Benita)
* Fixed scheduling class methods like ``B.methodname`` where the ``B`` class inherits
from class ``A`` and ``methodname`` is a class method of class ``A``
* Fixed scheduler sleeping for too long (and thus jobs missing their scheduled run
times) if its wakeup cycle takes too much time (fix by kbasten)


3.10.1
Expand Down

0 comments on commit fca40a7

Please sign in to comment.