Mark any over-attempted tasks as discarded
515574
function discardIfOverAttempted(tasksByName, count) {
      if (tasksByName) {
        taskUtils.getTasks(tasksByName).forEach(task => {
          const n = task.discardIfOverAttempted(maxNumberOfAttempts, true);
          if (count) overAttempted += n;
        });
      }
    }
632422
def do_discard(self, line):
        

        def f(p, args):
            print(p.discard_changes())

        self._request(line, f)
552291
async def cancel_remaining(self):
        ''''''
        self._closed = True
        task_list = list(self._pending)
        for task in task_list:
            task.cancel()
        for task in task_list:
            with suppress(CancelledError):
                await task
767407
def _cleanup(self):
        """"""
        if self.todolist.exists():
            try:
                saved_todo = iter(open(self.todolist, encoding="utf-8"))
                int(next(saved_todo).strip())
                for line in saved_todo:
                    _, serial = line.strip().split()
                    int(serial)
            except (StopIteration, ValueError):
                # The todo list was inconsistent. This may happen if we get
                # killed e.g. by the timeout wrapper. Just remove it - we'll
                # just have to do whatever happened since the last successful
                # sync.
                logger.info("Removing inconsistent todo list.")
                self.todolist.unlink()
398791
async def _clean_shutdown(self):
        """"""

        # Cleanly stop any other outstanding tasks not associated with tiles
        remaining_tasks = []
        for task in self._tasks.get(None, []):
            self._logger.debug("Cancelling task at shutdown %s", task)
            task.cancel()

            remaining_tasks.append(task)

        asyncio.gather(*remaining_tasks, return_exceptions=True)

        if len(remaining_tasks) > 0:
            del self._tasks[None]

        # Shutdown tasks associated with each tile
        remaining_tasks = []

        for address in sorted(self._tasks, reverse=True):
            if address is None:
                continue

            self._logger.debug("Shutting down tasks for tile at %d", address)
            for task in self._tasks.get(address, []):
                task.cancel()
                remaining_tasks.append(task)

        asyncio.gather(*remaining_tasks, return_exceptions=True)

        await self._rpc_queue.stop()

        self._loop.stop()
35138
def end_task(self):
        '''
        
        '''
        self.progress(self.task_stack[-1].size)
        self.task_stack.pop()
633321
public void cancelAllReservations() {
    // Inform jobs which have reserved slots on this tasktracker
    if (jobForFallowMapSlot != null) {
      unreserveSlots(TaskType.MAP, jobForFallowMapSlot);
    }
    if (jobForFallowReduceSlot != null) {
      unreserveSlots(TaskType.REDUCE, jobForFallowReduceSlot);
    }
  }
299007
def clean(self):
        """"""
        for _, i in self.tasks.items():
            i.cancel()
        self._heartbeat_task.cancel()
        self._response_task.cancel()
276122
def reset_for_retry(self):
    """"""
    self.retries += 1
    self.last_work_item = ""
    self.active = True
    self.result_status = None
    self.input_finished = False
    self.counters_map = CountersMap()
    self.slice_id = 0
    self.slice_start_time = None
    self.slice_request_id = None
    self.slice_retries = 0
    self.acquired_once = False
1285774
def _tasks_to_reinsert(tasks, transactional):
    
    if transactional:
        return tasks

    return [task for task in tasks if not task.was_enqueued]
567332
def purge(self, ignore_ignores):
        """"""
        command = ['sync', '#none']
        if ignore_ignores:
            command.append('--no-ignore')
        d = self._dovccmd(command, collectStdout=True)

        # add deferred to rm tree

        # then add defer to sync to revision
        return d
980432
def clear(self):
        """"""
        for key in list(self.queue.keys()):
            if self.queue[key]['status'] in ['done', 'failed']:
                del self.queue[key]
        self.write()
617743
async def _cancel(log, **tasks):
    
    for name, task in tasks.items():
        if not task:
            continue

        task.cancel()
        try:
            await task
        except asyncio.CancelledError:
            pass
        except Exception:
            log.exception('Unhandled exception from %s after cancel', name)
1084725
public void cancelQueuedTasks() {
      ArrayList<QueueingTask> queuedTasks = new ArrayList<QueueingTask>();
      queue.drainTo(queuedTasks);
      for (QueueingTask task : queuedTasks) {
         task.cancel(false);
      }
   }
987826
def _do_cancel_problems(self):
        
        try:
            while True:
                # Pull as many problems as we can, block when none are available.

                # `None` task is used to signal thread termination
                item = self._cancel_queue.get()
                if item is None:
                    break

                item_list = [item]
                while True:
                    try:
                        item_list.append(self._cancel_queue.get_nowait())
                    except queue.Empty:
                        break

                # Submit the problems, attach the ids as a json list in the
                # body of the delete query.
                try:
                    body = [item[0] for item in item_list]

                    try:
                        self.session.delete(posixpath.join(self.endpoint, 'problems/'), json=body)
                    except requests.exceptions.Timeout:
                        raise RequestTimeout

                except Exception as err:
                    for _, future in item_list:
                        if future is not None:
                            future._set_error(err, sys.exc_info())

                # Mark all the ids as processed regardless of success or failure.
                [self._cancel_queue.task_done() for _ in item_list]

                # this is equivalent to a yield to scheduler in other threading libraries
                time.sleep(0)

        except Exception as err:
            _LOGGER.exception(err)
1010979
def cleanup(self):
        
        if self.transport:
            self.transport.close()
            self.transport = None
        if self.task:
            self.task.cancel()
            self.task = None
        for light in self.lights.values():
            light.cleanup()
        self.lights = {}
922971
def cleanup(self):
        """"""
        expires = maybe_timedelta(self.expires)
        for model in self.TaskModel, self.TaskSetModel:
            model._default_manager.delete_expired(expires)