code: def cancel(**kwargs):
      
      task_list = _query(**kwargs)
      for task in task_list:
          task.status = WorkQueue.CANCELED
          task.finished = datetime.datetime.utcnow()
          db.session.add(task)
      return len(task_list)
docs: Cancels work items based on their criteria.
  
      Args:
          **kwargs: Same parameters as the query() method.
  
      Returns:
          The number of tasks that were canceled.