From 762cecde3a15f99a50b718fb226b627993265e72 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 14 Oct 2024 18:20:11 +0300 Subject: [PATCH] docs: make sure that `channels` use `finally` in all examples --- docs/usage/channels.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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