Skip to content

Commit 323d09d

Browse files
committed
Added __aexit__ and __aenter__ support.
1 parent 3d83293 commit 323d09d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎taskiq/abc/broker.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,3 +533,11 @@ def _register_task(
533533
if task.broker != self:
534534
raise TaskBrokerMismatchError(broker=task.broker)
535535
self.local_task_registry[task_name] = task
536+
537+
async def __aenter__(self) -> None:
538+
"""Satarts the broker as ctx manager."""
539+
await self.startup()
540+
541+
async def __aexit__(self, *args: object, **kwargs: Any) -> None:
542+
"""Shuts down the broker as ctx manager."""
543+
await self.shutdown()

0 commit comments

Comments
 (0)