Closes any tasks currently in progress
18553
@Override
    public void close()
    {
        isOpen.set(false);
        Iterator<Future<?>> iterator = futures.iterator();
        while ( iterator.hasNext() )
        {
            Future<?> future = iterator.next();
            iterator.remove();
            if ( !future.isDone() && !future.isCancelled() && !future.cancel(true) )
            {
                log.warn("Could not cancel " + future);
            }
        }
        if (shutdownOnClose) {
            executorService.shutdownNow();
        }
    }
50208
@LifecycleStop
  public void stop()
  {
    giant.lock();

    try {
      tasks.clear();
      taskFutures.clear();
      active = false;
      managerExec.shutdownNow();
      storageSyncExec.shutdownNow();
      managementMayBeNecessary.signalAll();
    }
    finally {
      giant.unlock();
    }
  }
136206
async def stop(self):
        
        if self._task is not None:
            self._task.cancel()
            self._task = None

        if self._state in [State.CONNECTING, State.CONNECTED]:
            lib.SSL_shutdown(self.ssl)
            try:
                await self._write_ssl()
            except ConnectionError:
                pass
            self.__log_debug('- DTLS shutdown complete')
445252
public void close() throws IOException {
    LOG.info(getTask()+" done; removing files.");
    getTask().getProgress().setStatus("closed");
    mapOutputFile.removeAll(getTask().getTaskID());
  }
522525
def stop(self):
        
        try:
            self.running = False
            logger.info('Waiting tasks to finish...')
            self.queue.join()
            self.socket.close()
            logger.info('Exiting (C-Ctrl again to force it)...')
        except KeyboardInterrupt:
            logger.info('Forced.')
            sys.exit(1)
1160837
def _close_and_clean(self, cleanup):
        

        tasks = []
        for node in self._nodes:
            tasks.append(asyncio.async(node.manager.close_node(node.id)))

        if tasks:
            done, _ = yield from asyncio.wait(tasks)
            for future in done:
                try:
                    future.result()
                except (Exception, GeneratorExit) as e:
                    log.error("Could not close node {}".format(e), exc_info=1)

        if cleanup and os.path.exists(self.path):
            self._deleted = True
            try:
                yield from wait_run_in_executor(shutil.rmtree, self.path)
                log.info("Project {id} with path '{path}' deleted".format(path=self._path, id=self._id))
            except OSError as e:
                raise aiohttp.web.HTTPInternalServerError(text="Could not delete the project directory: {}".format(e))
        else:
            log.info("Project {id} with path '{path}' closed".format(path=self._path, id=self._id))

        if self._used_tcp_ports:
            log.warning("Project {} has TCP ports still in use: {}".format(self.id, self._used_tcp_ports))
        if self._used_udp_ports:
            log.warning("Project {} has UDP ports still in use: {}".format(self.id, self._used_udp_ports))

        # clean the remaining ports that have not been cleaned by their respective node.
        port_manager = PortManager.instance()
        for port in self._used_tcp_ports.copy():
            port_manager.release_tcp_port(port, self)
        for port in self._used_udp_ports.copy():
            port_manager.release_udp_port(port, self)
571138
public void stop()
  {
    synchronized (startStopLock) {
      running = false;
      taskStatusChecker.shutdownNow();

      if (numRunningTasks > 0) {
        final Iterator<MonitorEntry> iterator = runningTasks.values().iterator();
        while (iterator.hasNext()) {
          final MonitorEntry entry = iterator.next();
          iterator.remove();
          final String taskId = entry.runningTask.getId();
          log.info("Request to kill subtask[%s]", taskId);
          indexingServiceClient.killTask(taskId);
          numRunningTasks--;
          numKilledTasks++;
        }

        if (numRunningTasks > 0) {
          log.warn(
              "Inconsistent state: numRunningTasks[%d] is still not zero after trying to kill all running tasks.",
              numRunningTasks
          );
        }
      }

      log.info("Stopped taskMonitor");
    }
  }
959845
def stop(self) -> None:
        

        self._shutdown = True

        # Close connection if needed
        self._protocol.close()

        # Cancel any pending tasks
        self.cancel_pending_tasks()
555115
def stop(self, block=True):
        
        self._stop = True

        # Removing tasks in queue
        self.empty_queue()

        # All active threads
        # With the DoNothing function
        # Because self._stop is True each thread will process at most one of the DoNothing functions
        # Hence it is ensured that all .get calls are triggered
        for _ in range(self.threads_active()):
            self._queue.put(SetPrio(target=DoNothing))

        if block:
            # Blocking until all threads are closed
            self.join()

            # Removing any leftover DoNothing functions (Can only be reliably done when all threads are closed)
            self.empty_queue()
748505
function() {
    firstTaskTimeout = clearTimeout(firstTaskTimeout);
    const task = taskQueue.shift();

    if (task) {
      const conn = idleConnections.shift();
      if (conn) {
        activeConnections[conn.threadId] = conn;
        resetTimeoutToNextTask();
        processTask(conn, task.sql, task.values, task.isBatch)
          .then(task.resolve)
          .catch(task.reject);
      } else {
        taskQueue.unshift(task);
      }
    }
  }
572812
def shutdown(self):
        """"""
        self.stop_all_periodic_tasks()
        for channel in self._bcm_sockets:
            log.debug("Closing bcm socket for channel {}".format(channel))
            bcm_socket = self._bcm_sockets[channel]
            bcm_socket.close()
        log.debug("Closing raw can socket")
        self.socket.close()
456933
protected void stop() {
        this.authenticating = false;
        // clear batcher
        batcher.clear();
        // set non-continuous
        setLifecycle(Replication.Lifecycle.ONESHOT);
        // cancel if middle of retry
        cancelRetryFuture();
        // cancel all pending future tasks.
        while (!pendingFutures.isEmpty()) {
            Future future = pendingFutures.poll();
            if (future != null && !future.isCancelled() && !future.isDone()) {
                future.cancel(true);
                CancellableRunnable runnable = cancellables.get(future);
                if (runnable != null) {
                    runnable.cancel();
                    cancellables.remove(future);
                }
            }
        }
    }
64687
private void purgeTask(TaskInProgress tip, boolean wasFailure)
  throws IOException {
    if (tip != null) {
      LOG.info("About to purge task: " + tip.getTask().getTaskID());

      // Remove the task from running jobs,
      // removing the job if it's the last task
      removeTaskFromJob(tip.getTask().getJobID(), tip);
      tip.jobHasFinished(wasFailure);
      if (tip.getTask().isMapTask()) {
        indexCache.removeMap(tip.getTask().getTaskID().toString());
      }
    }
  }
812645
def close(self):
        """"""
        self._closed = True
        if self.receive_task:
            self.receive_task.cancel()
        if self.connection:
            self.connection.close()
1155184
@Override
    public void close() {
        synchronized (startedTasks) {
            if (executor.isShutdown()) {
                return;
            }
            // ... stop updater thread. Do not interrupt.
            executor.shutdown();
            try {
                updater.get();
            } catch (InterruptedException | CancellationException | ExecutionException ignore) {
                // Ignore these closing thread errors.
            }
            // And stop all the tasks, do interrupting.
            for (InternalTask task : startedTasks) {
                task.cancel(true);
            }
            for (InternalTask task : queuedTasks) {
                task.close();
            }

            try {
                executor.awaitTermination(100L, TimeUnit.MILLISECONDS);
            } catch (InterruptedException ignore) {
                Thread.currentThread().interrupt();
            }
        }
    }
1359634
async def cancel(self):
        """"""
        self.is_cancelled = True
        if self.future is not None:
            self.future.cancel()
        if self.task_process is not None:
            log.warning("Worker is shutting down, but a task is running. Terminating task")
            await self.task_process.worker_shutdown_stop()
683383
def task_done(self):
        """"""
        with self._lock:
            unfinished = self._unfinished_tasks - 1
            if unfinished < 0:
                raise RuntimeError('task_done() called too many times')
            elif unfinished == 0:
                self._alldone.notify()
            self._unfinished_tasks = unfinished