summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2021-01-13 13:37:06 +0200
committerAlex Grönholm <alex.gronholm@nextday.fi>2021-01-13 13:37:06 +0200
commit0b02d77ef70bdc16a7f2ed65d9b6bbb5b15c17a9 (patch)
tree63ac619a0664ba13f82064c67325d5be812dc2d3
parent1002af0ef3d01dbafdd1f3810f266ebcdb64ac9b (diff)
downloadapscheduler-0b02d77ef70bdc16a7f2ed65d9b6bbb5b15c17a9.tar.gz
Get the asyncio event loop in start() and not in __init()__
Fixes #484.
-rw-r--r--apscheduler/schedulers/asyncio.py8
-rw-r--r--docs/versionhistory.rst3
2 files changed, 10 insertions, 1 deletions
diff --git a/apscheduler/schedulers/asyncio.py b/apscheduler/schedulers/asyncio.py
index 289ef13..9ab7221 100644
--- a/apscheduler/schedulers/asyncio.py
+++ b/apscheduler/schedulers/asyncio.py
@@ -38,13 +38,19 @@ class AsyncIOScheduler(BaseScheduler):
_eventloop = None
_timeout = None
+ def start(self, paused=False):
+ if not self._eventloop:
+ self._eventloop = asyncio.get_event_loop()
+
+ super().start(paused)
+
@run_in_event_loop
def shutdown(self, wait=True):
super(AsyncIOScheduler, self).shutdown(wait)
self._stop_timer()
def _configure(self, config):
- self._eventloop = maybe_ref(config.pop('event_loop', None)) or asyncio.get_event_loop()
+ self._eventloop = maybe_ref(config.pop('event_loop', None))
super(AsyncIOScheduler, self)._configure(config)
def _start_timer(self, wait_seconds):
diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst
index 578f496..772b520 100644
--- a/docs/versionhistory.rst
+++ b/docs/versionhistory.rst
@@ -12,6 +12,9 @@ APScheduler, see the :doc:`migration section <migration>`.
* Pinned ``tzlocal`` to a version compatible with pytz
* Ensured that jitter is always non-negative to prevent triggers from firing more often than
intended
+* Changed ``AsyncIOScheduler`` to obtain the event loop in ``start()`` instead of ``__init__()``,
+ to prevent situations where the scheduler won't run because it's using a different event loop
+ than then one currently running
* Made it possible to create weak references to ``Job`` instances
* Fixed Zookeeper job store using backslashes instead of forward slashes for paths
on Windows (PR by Laurel-rao)