From: Ben Darnell Date: Mon, 3 Aug 2015 03:57:27 +0000 (-0400) Subject: Expand comment on `async with`. X-Git-Tag: v4.3.0b1~63^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7130c1ebc548998e8b0ab94410e1a751b270396;p=thirdparty%2Ftornado.git Expand comment on `async with`. --- 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)