for 'amqtt' (broker script) was creating a new event loop but not passing it to the broker, so the broker was running in one event loop and all of its coroutines were executing in another, not a supported behavior

pull/219/head
Andrew Mirsky 2025-06-14 23:30:10 -04:00
rodzic a43f81a9b1
commit e738335c7f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: A98E67635CDF2C39
2 zmienionych plików z 2 dodań i 3 usunięć

Wyświetl plik

@ -180,7 +180,7 @@ class Broker:
self.config.update(config) self.config.update(config)
self._build_listeners_config(self.config) self._build_listeners_config(self.config)
self._loop = loop or asyncio.new_event_loop() self._loop = loop or asyncio.get_running_loop()
self._servers: dict[str, Server] = {} self._servers: dict[str, Server] = {}
self._init_states() self._init_states()
self._sessions: dict[str, tuple[Session, BrokerProtocolHandler]] = {} self._sessions: dict[str, tuple[Session, BrokerProtocolHandler]] = {}

Wyświetl plik

@ -54,11 +54,10 @@ def broker_main(
typer.echo(f"❌ Config file error: {exc}", err=True) typer.echo(f"❌ Config file error: {exc}", err=True)
raise typer.Exit(code=1) from exc raise typer.Exit(code=1) from exc
loop = asyncio.new_event_loop() loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop) asyncio.set_event_loop(loop)
try: try:
broker = Broker(config) broker = Broker(config, loop=loop)
except (BrokerError, ParserError, PluginError) as exc: except (BrokerError, ParserError, PluginError) as exc:
typer.echo(f"❌ Broker failed to start: {exc}", err=True) typer.echo(f"❌ Broker failed to start: {exc}", err=True)
raise typer.Exit(code=1) from exc raise typer.Exit(code=1) from exc