'Acquire resource.
Arguments:
block (bool): If the limit is exceeded,
then block until there is an available item.
timeout (float): Timeout to wait
if ``block`` is true.  Default is :const:`None` (forever).
Raises:
LimitExceeded: if block is false and the limit has been exceeded.'

def acquire(self, block=False, timeout=None):

    if self._closed:
        raise RuntimeError(u'Acquire    on    closed    pool')
    if self.limit:
        while 1:
            try:
                R = self._resource.get(block=block, timeout=timeout)
            except Empty:
                self._add_when_empty()
            else:
                try:
                    R = self.prepare(R)
                except BaseException:
                    if isinstance(R, lazy):
                        self._resource.put_nowait(R)
                    else:
                        self.release(R)
                    raise
                self._dirty.add(R)
                break
    else:
        R = self.prepare(self.new())
    def release():
        u'Release    resource    so    it    can    be    used    by    another    thread.\n\n                                                Warnings:\n                                                                The    caller    is    responsible    for    discarding    the    object,\n                                                                and    to    never    use    the    resource    again.        A    new    resource    must\n                                                                be    acquired    if    so    needed.\n                                                '
        self.release(R)
    R.release = release
    return R
