(self)
return True
Acquire a lock.

        This method blocks until the lock is unlocked, then sets it to
        locked and returns True.
Acquire a lock.
Acquire a lock .
async def acquire(self):
        """Acquire a lock.

        This method blocks until the lock is unlocked, then sets it to
        locked and returns True.
        """
        if (not self._locked and (self._waiters is None or
                all(w.cancelled() for w in self._waiters))):
            self._locked = True
            return True

        if self._waiters is None:
            self._waiters = collections.deque()
        fut = self._get_loop().create_future()
        self._waiters.append(fut)

        # Finally block should be called before the CancelledError
        # handling as we don't want CancelledError to call
        # _wake_up_first() and attempt to wake up itself.
        try:
            try:
                await fut
            finally:
                self._waiters.remove(fut)
        except exceptions.CancelledError:
            if not self._locked:
                self._wake_up_first()
            raise

        self._locked = True
        return True
async def acquire ( self ) : if ( not self . _locked and ( self . _waiters is None or all ( w . cancelled ( ) for w in self . _waiters ) ) ) : self . _locked = True return True if self . _waiters is None : self . _waiters = collections . deque ( ) fut = self . _get_loop ( ) . create_future ( ) self . _waiters . append ( fut ) # Finally block should be called before the CancelledError # handling as we don't want CancelledError to call # _wake_up_first() and attempt to wake up itself. try : try : await fut finally : self . _waiters . remove ( fut ) except exceptions . CancelledError : if not self . _locked : self . _wake_up_first ( ) raise self . _locked = True return True