From d7130c1ebc548998e8b0ab94410e1a751b270396 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 2 Aug 2015 23:57:27 -0400 Subject: [PATCH] Expand comment on `async with`. --- tornado/locks.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tornado/locks.py b/tornado/locks.py index 746b1977b..a18177286 100644 --- a/tornado/locks.py +++ b/tornado/locks.py @@ -453,8 +453,10 @@ class Lock(object): ... ... # Now the lock is released. - In Python 3.5, `Lock` also supports the async context manager protocol. - Note that in this case there is no `acquire`: + In Python 3.5, `Lock` also supports the async context manager + protocol. Note that in this case there is no `acquire`, because + ``async with`` includes both the ``yield`` and the ``acquire`` + (just as it does with `threading.Lock`): >>> async def f(): # doctest: +SKIP ... async with lock: @@ -465,6 +467,7 @@ class Lock(object): .. versionchanged:: 3.5 Added ``async with`` support in Python 3.5. + """ def __init__(self): self._block = BoundedSemaphore(value=1) -- 2.47.2