def add_msg_handler(self, handler_fn: HandlerFn) -> SubscriptionAPI: self._msg_handlers.add(handler_fn) cancel_fn = functools.partial(self._msg_handlers.remove, handler_fn) return Subscription(cancel_fn)