diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2022-07-26 15:14:15 +0300 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2022-07-27 13:02:08 +0300 |
commit | ad4fd007ab4e72e6eda7fee263b8976c19aa993b (patch) | |
tree | 26fce3398c61af3d686fe0c277fabd7be6d53e12 /tests | |
parent | aca1ee95abf41272c04cbc60535f56a1f1587e7f (diff) | |
download | apscheduler-ad4fd007ab4e72e6eda7fee263b8976c19aa993b.tar.gz |
Improved the scheduler lifecycle management
Both sync and async schedulers now have consistently working stop() and wait_until_stopped() methods.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_schedulers.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_schedulers.py b/tests/test_schedulers.py index e33a91e..ab49abe 100644 --- a/tests/test_schedulers.py +++ b/tests/test_schedulers.py @@ -214,6 +214,17 @@ class TestAsyncScheduler: else: assert result.outcome is JobOutcome.success + async def test_wait_until_stopped(self) -> None: + async with AsyncScheduler() as scheduler: + trigger = DateTrigger( + datetime.now(timezone.utc) + timedelta(milliseconds=100) + ) + await scheduler.add_schedule(scheduler.stop, trigger) + await scheduler.wait_until_stopped() + + # This should be a no-op + await scheduler.wait_until_stopped() + class TestSyncScheduler: def test_schedule_job(self): @@ -365,3 +376,14 @@ class TestSyncScheduler: raise result.exception else: assert result.outcome is JobOutcome.success + + def test_wait_until_stopped(self) -> None: + with Scheduler() as scheduler: + trigger = DateTrigger( + datetime.now(timezone.utc) + timedelta(milliseconds=100) + ) + scheduler.add_schedule(scheduler.stop, trigger) + scheduler.wait_until_stopped() + + # This should be a no-op + scheduler.wait_until_stopped() |