'Decrement the counter. Returns a Future.
Block if the counter is zero and wait for a `.release`. The Future
raises `.TimeoutError` after the deadline.'

def acquire(self, timeout=None):

    waiter = Future()
    if (self._value > 0):
        self._value -= 1
        waiter.set_result(_ReleasingContextManager(self))
    else:
        self._waiters.append(waiter)
        if timeout:
            def on_timeout():
                waiter.set_exception(gen.TimeoutError())
                self._garbage_collect()
            io_loop = ioloop.IOLoop.current()
            timeout_handle = io_loop.add_timeout(timeout, on_timeout)
            waiter.add_done_callback((lambda _: io_loop.remove_timeout(timeout_handle)))
    return waiter
