diff options
Diffstat (limited to 'src/apscheduler/eventbrokers/async_adapter.py')
-rw-r--r-- | src/apscheduler/eventbrokers/async_adapter.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/apscheduler/eventbrokers/async_adapter.py b/src/apscheduler/eventbrokers/async_adapter.py index c10ac56..a91aae3 100644 --- a/src/apscheduler/eventbrokers/async_adapter.py +++ b/src/apscheduler/eventbrokers/async_adapter.py @@ -29,8 +29,9 @@ class AsyncEventBrokerAdapter(LocalAsyncEventBroker): self._exit_stack.push_async_exit(partial(to_thread.run_sync, self.original.__exit__)) # Relay events from the original broker to this one - relay_subscription = self.original.subscribe(partial(self.portal.call, self.publish_local)) - self._exit_stack.callback(relay_subscription.unsubscribe) + self._exit_stack.enter_context( + self.original.subscribe(partial(self.portal.call, self.publish_local)) + ) async def publish(self, event: Event) -> None: await to_thread.run_sync(self.original.publish, event) |