diff --git a/docs/usage/channels.rst b/docs/usage/channels.rst index 5d9fd8daf4..e139adb60a 100644 --- a/docs/usage/channels.rst +++ b/docs/usage/channels.rst @@ -219,8 +219,10 @@ subscriptions need to be managed dynamically. .. code-block:: python subscriber = await channels.subscribe(["foo", "bar"]) - ... # do some stuff here - await channels.unsubscribe(subscriber, ["foo"]) + try: + ... # do some stuff here + finally: + await channels.unsubscribe(subscriber, ["foo"]) Or, using the context manager