import asyncio from typing import Optional from cpl_core.application import ApplicationABC, ApplicationBuilder from gismo.application import Application from gismo.startup import Startup from modules.boot_log.boot_log_extension import BootLogExtension class Main: def __init__(self): self._app: Optional[ApplicationABC] = None async def main(self): app_builder = ApplicationBuilder(Application) app_builder.use_extension(BootLogExtension) app_builder.use_startup(Startup) self._app: ApplicationABC = await app_builder.build_async() await self._app.run_async() async def stop(self): await self._app.stop_async() if __name__ == '__main__': main = Main() ml = asyncio.get_event_loop() try: ml.run_until_complete(main.main()) except KeyboardInterrupt: ml.run_until_complete(main.stop())