Skip to content

Commit 5cfc938

Browse files
committed
refactor(Runner): make infinite while loop exit on shutdown_signal
1 parent 7f48d7f commit 5cfc938

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

silverback/runner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async def _cron_tasks(self, cron_tasks: list[TaskData]):
135135
Handle all cron tasks
136136
"""
137137

138-
while True:
138+
while not self.shutdown_event.is_set():
139139
# NOTE: Sleep until next exact time boundary (every minute)
140140
current_time = utc_now()
141141
wait_time = timedelta(
@@ -333,12 +333,12 @@ async def run(self):
333333
If there are no configured tasks to execute.
334334
"""
335335

336-
# NOTE: No need to display startup text, obvious from loading settings
337-
user_tasks = await self.startup()
338-
339336
# NOTE: After startup, we need to gracefully shutdown
340337
self.shutdown_event = asyncio.Event()
341338

339+
# NOTE: No need to display startup text, obvious from loading settings
340+
user_tasks = await self.startup()
341+
342342
def exit_handler(signum, _frame):
343343
logger.info(f"{signal.Signals(signum).name} signal received")
344344
self.shutdown_event.set()

0 commit comments

Comments
 (0)