Fixed workflow data propagation (#1196)

* Coverage

* Added changelog
This commit is contained in:
Alex Root Junior 2023-06-25 01:11:00 +03:00 committed by GitHub
parent a890622e40
commit 484a61bdc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

1
CHANGES/1196.bugfix.rst Normal file
View file

@ -0,0 +1 @@
Fixed workflow data propagation

View file

@ -500,11 +500,10 @@ class Dispatcher(Router):
workflow_data = {
"dispatcher": self,
"bots": bots,
"bot": bots[-1],
**kwargs,
**self.workflow_data,
**kwargs,
}
await self.emit_startup(**workflow_data)
await self.emit_startup(bot=bots[-1], **workflow_data)
loggers.dispatcher.info("Start polling")
try:
tasks: List[asyncio.Task[Any]] = [
@ -515,7 +514,7 @@ class Dispatcher(Router):
polling_timeout=polling_timeout,
backoff_config=backoff_config,
allowed_updates=allowed_updates,
**kwargs,
**workflow_data,
)
)
for bot in bots
@ -534,7 +533,7 @@ class Dispatcher(Router):
finally:
loggers.dispatcher.info("Polling stopped")
try:
await self.emit_shutdown(**workflow_data)
await self.emit_shutdown(bot=bots[-1], **workflow_data)
finally:
if close_bot_session:
await asyncio.gather(*(bot.session.close() for bot in bots))

View file

@ -28,8 +28,8 @@ def setup_application(app: Application, dispatcher: Dispatcher, /, **kwargs: Any
workflow_data = {
"app": app,
"dispatcher": dispatcher,
**kwargs,
**dispatcher.workflow_data,
**kwargs,
}
async def on_startup(*a: Any, **kw: Any) -> None: # pragma: no cover