Add clean-up logics into TrioSubscriptionAPI

Register an `unsubscribe_fn` when initializing the TrioSubscriptionAPI.
`unsubscribe_fn` is called when subscription is unsubscribed.
This commit is contained in:
mhchia
2020-01-28 00:29:05 +08:00
parent c3ba67ea87
commit 095a848f30
6 changed files with 70 additions and 16 deletions

View File

@ -24,7 +24,7 @@ class ISubscriptionAPI(
AsyncContextManager["ISubscriptionAPI"], AsyncIterable[rpc_pb2.Message]
):
@abstractmethod
async def cancel(self) -> None:
async def unsubscribe(self) -> None:
...
@abstractmethod