update workflow data

This commit is contained in:
sheldy 2023-09-08 23:12:51 +03:00
parent 28cc2384e8
commit 655f061007

View file

@ -511,16 +511,11 @@ class Dispatcher(Router):
signal.SIGINT, self._signal_stop_polling, signal.SIGINT
)
workflow_data = {
"dispatcher": self,
"bots": bots,
**self.workflow_data,
**kwargs,
}
if "bot" in workflow_data:
workflow_data.pop("bot")
self.workflow_data.update({"dispatcher": self, "bots": bots, **kwargs})
if "bot" in self.workflow_data:
self.workflow_data.pop("bot")
await self.emit_startup(bot=bots[-1], **workflow_data)
await self.emit_startup(bot=bots[-1], **self.workflow_data)
loggers.dispatcher.info("Start polling")
try:
tasks: List[asyncio.Task[Any]] = [
@ -531,7 +526,7 @@ class Dispatcher(Router):
polling_timeout=polling_timeout,
backoff_config=backoff_config,
allowed_updates=allowed_updates,
**workflow_data,
**self.workflow_data,
)
)
for bot in bots
@ -550,7 +545,7 @@ class Dispatcher(Router):
finally:
loggers.dispatcher.info("Polling stopped")
try:
await self.emit_shutdown(bot=bots[-1], **workflow_data)
await self.emit_shutdown(bot=bots[-1], **self.workflow_data)
finally:
if close_bot_session:
await asyncio.gather(*(bot.session.close() for bot in bots))