]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Expand comment on `async with`. 1476/head
authorBen Darnell <ben@bendarnell.com>
Mon, 3 Aug 2015 03:57:27 +0000 (23:57 -0400)
committerBen Darnell <ben@bendarnell.com>
Mon, 3 Aug 2015 03:57:27 +0000 (23:57 -0400)
tornado/locks.py

index 746b1977b0157dc6d059841aaa926d8dffedb872..a1817728611ec77240c4055043038984bf3752fc 100644 (file)
@@ -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)