code: 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
docs: 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.