From fca40a73007c075fa22e965f1462e34b5e8b7bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Sun, 13 Aug 2023 00:59:36 +0300 Subject: [PATCH] Calculate sleep time based on a recent call to datetime.now() Closes #754. --- apscheduler/schedulers/base.py | 1 + docs/versionhistory.rst | 2 ++ 2 files changed, 3 insertions(+) diff --git a/apscheduler/schedulers/base.py b/apscheduler/schedulers/base.py index 3ce2bfc52..aba723f48 100644 --- a/apscheduler/schedulers/base.py +++ b/apscheduler/schedulers/base.py @@ -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) diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst index ec551e72d..ea0357184 100644 --- a/docs/versionhistory.rst +++ b/docs/versionhistory.rst @@ -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