parameters: (self)
return_statement: return True
docstring: Cancel the future if possible.
  
          Returns True if the future was cancelled, False otherwise. A future
          cannot be cancelled if it is running or has already completed.
docstring_summary: Cancel the future if possible.
docstring_tokens: Cancel the future if possible .
function: def cancel(self):
          """Cancel the future if possible.
  
          Returns True if the future was cancelled, False otherwise. A future
          cannot be cancelled if it is running or has already completed.
          """
          with self._condition:
              if self._state in [RUNNING, FINISHED]:
                  return False
  
              if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
                  return True
  
              self._state = CANCELLED
              self._condition.notify_all()
  
          self._invoke_callbacks()
          return True
function_tokens: def cancel ( self ) : with self . _condition : if self . _state in [ RUNNING , FINISHED ] : return False if self . _state in [ CANCELLED , CANCELLED_AND_NOTIFIED ] : return True self . _state = CANCELLED self . _condition . notify_all ( ) self . _invoke_callbacks ( ) return True