code: def _cancel(self, action: Callable = None, aid: int = None):
          
          if action is not None:
              if action in self.scheduled:
                  logger.trace("{} cancelling all events for action {}, ids: {}"
                               "".format(self, action, self.scheduled[action]))
                  self.scheduled[action].clear()
          elif aid is not None:
              for action, aids in self.scheduled.items():
                  try:
                      aids.remove(aid)
                  except ValueError:
                      pass
                  else:
                      logger.trace("{} cancelled action {} with id {}".format(self, action, aid))
                      break
docs: Cancel scheduled events
  
          :param action:  (optional) scheduled action. If specified, all
                  scheduled events for the action are cancelled.
          :param aid:     (options) scheduled event id. If specified,
                  scheduled event with the aid is cancelled.