from typing import Dict
-restart = True
-
async def shutdown(sig: signal.Signals) -> None:
"""Shutdown the system in reaction to a signal."""
- global restart
print(f"Shutting down on signal {sig.name}.")
- restart = False
for task in asyncio.all_tasks():
if task is not asyncio.current_task():
task.cancel()
async def main() -> None:
"""Set up signal handlers, read configuration file and run system."""
- global restart
await add_signal_handlers()
notifier = await add_config_change_handler()
- while restart:
- conf = read_configuration()
- await run(conf)
+ conf = read_configuration()
+ await run(conf)
notifier.stop()
if __name__ == '__main__':