Fix tasks not dispatching

This commit is contained in:
arabcoders 2025-06-23 12:56:00 +03:00
parent 3e00ebd067
commit fdec2356f9

View file

@ -38,15 +38,10 @@ class Main:
def __init__(self, is_native: bool = False):
self._config = Config.get_instance(is_native=is_native)
self._app = web.Application()
self.loop = asyncio.new_event_loop()
self._app.on_shutdown.append(self.on_shutdown)
Services.get_instance().add("app", self._app)
if self._config.debug:
self.loop.set_debug(True)
self.loop.slow_callback_duration = 0.05
self._check_folders()
caribou.upgrade(self._config.db_file, ROOT_PATH / "migrations")
@ -127,7 +122,13 @@ class Main:
LOG.info(f"YTPTube {self._config.version} - started on http://{host}:{port}{self._config.base_path}")
LOG.info("=" * 40)
EventBus.get_instance().sync_emit(Events.STARTED, data={"app": self._app}, loop=self.loop, wait=False)
loop = asyncio.get_event_loop()
EventBus.get_instance().sync_emit(Events.STARTED, data={"app": self._app}, loop=loop, wait=False)
if loop and self._config.debug:
loop.set_debug(True)
loop.slow_callback_duration = 0.05
if cb:
cb()
@ -145,7 +146,7 @@ class Main:
host=host,
port=port,
reuse_port="win32" != sys.platform,
loop=self.loop,
loop=asyncio.get_event_loop(),
access_log=HTTP_LOGGER,
print=started,
handle_signals=cb is None,