parameters: (self)
return_statement: return True
docstring: Acquire a lock.
  
          This method blocks until the lock is unlocked, then sets it to
          locked and returns True.
docstring_summary: Acquire a lock.
docstring_tokens: Acquire a lock .
function: 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 all(w.cancelled() for w in self._waiters):
              self._locked = True
              return True
  
          fut = self._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 futures.CancelledError:
              if not self._locked:
                  self._wake_up_first()
              raise
  
          self._locked = True
          return True
function_tokens: async def acquire ( self ) : if not self . _locked and all ( w . cancelled ( ) for w in self . _waiters ) : self . _locked = True return True fut = self . _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 futures . CancelledError : if not self . _locked : self . _wake_up_first ( ) raise self . _locked = True return True