class_docstr: A lock for coroutines.
  
  A Lock begins unlocked, and `acquire` locks it immediately. While it is
  locked, a coroutine that yields `acquire` waits until another coroutine
  calls `release`.
  
  Releasing an unlocked lock raises `RuntimeError`.
  
  `acquire` supports the context manager protocol in all Python versions:
  
  >>> from tornado import gen, locks
  >>> lock = locks.Lock()
  >>>
  >>> @gen.coroutine
  ... def f():
  ...    with (yield lock.acquire()):
  ...        # Do something holding the lock.
  ...        pass
  ...
  ...    # 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`, 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:
  ...        # Do something holding the lock.
  ...        pass
  ...
  ...    # Now the lock is released.
  
  .. versionchanged:: 4.3
     Added ``async with`` support in Python 3.5.
class_docstr_tok: ["A","lock","for","coroutines",".","A","Lock","begins","unlocked",",","and","`","acquire","`","locks","it","immediately",".","While","it","is","locked",",","a","coroutine","that","yields","`","acquire","`","waits","until","another","coroutine","calls","`","release","`",".","Releasing","an","unlocked","lock","raises","`","RuntimeError","`",".","`","acquire","`","supports","the","context","manager","protocol","in","all","Python","versions",":",">",">",">","from","tornado","import","gen",",","locks",">",">",">","lock","=","locks.Lock","(",")",">",">",">",">",">",">","@","gen.coroutine","...","def","f","(",")",":","...","with","(","yield","lock.acquire","(",")",")",":","...","#","Do","something","holding","the","lock",".","...","pass","...","...","#","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","`",",","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",":","...","#","Do","something","holding","the","lock",".","...","pass","...","...","#","Now","the","lock","is","released",".","..","versionchanged",":",":","4.3","Added","``","async","with","``","support","in","Python","3.5","."]
code: def __init__(self):
      self._block = BoundedSemaphore(value=1)
  
imports: from __future__ import absolute_import, division, print_function
  import collections
  from tornado import gen, ioloop
  from tornado.concurrent import Future
label_desc: Use image node_id 1 to create a new Lock object from inherited base classes: object with example: obj = Lock()