Worker thread for CLMFile.prune_tour()
348199
def prune_tour_worker(arg):
    
    from .chic import score_evaluate_M

    t, stour, tour_score, active_sizes, M = arg
    stour_score, = score_evaluate_M(stour, active_sizes, M)
    delta_score = tour_score - stour_score
    log10d = np.log10(delta_score) if delta_score > 1e-9 else -9
    return t, log10d
753126
@SuppressWarnings("FutureReturnValueIgnored")
  private void deleteProjectDirsInParallel(final ImmutableSet<File> projectDirsToDelete) {
    final int CLEANING_SERVICE_THREAD_NUM = 8;
    final ExecutorService deletionService = Executors
        .newFixedThreadPool(CLEANING_SERVICE_THREAD_NUM);

    for (final File toDelete : projectDirsToDelete) {
      deletionService.submit(() -> {
        log.info("Deleting project dir {} from project cache to free up space", toDelete);
        FileIOUtils.deleteDirectorySilently(toDelete);
      });
    }

    try {
      new ExecutorServiceUtils().gracefulShutdown(deletionService, Duration.ofDays(1));
    } catch (final InterruptedException e) {
      log.warn("Error when deleting files", e);
    }
  }
1257843
def workerCleanup(info):
        
        assert isinstance(info, WorkerCleanupInfo)
        workflowDir = Toil.getWorkflowDir(info.workflowID, info.workDir)
        workflowDirContents = os.listdir(workflowDir)
        shutdownFileStore(workflowDir, info.workflowID)
        if (info.cleanWorkDir == 'always'
            or info.cleanWorkDir in ('onSuccess', 'onError')
            and workflowDirContents in ([], [cacheDirName(info.workflowID)])):
            shutil.rmtree(workflowDir)
57139
def prune_dead_workers
      all_workers = self.class.all
      return if all_workers.empty?
      known_workers = JRUBY ? worker_thread_ids : []
      pids = nil, hostname = self.hostname
      all_workers.each do |worker|
        host, pid, thread, queues = self.class.split_id(worker.id)
        next if host != hostname
        next if known_workers.include?(thread) && pid == self.pid.to_s
        # NOTE: allow flexibility of running workers :
        # 1. worker might run in another JVM instance
        # 2. worker might run as a process (with MRI)
        next if (pids ||= system_pids).include?(pid)
        log! "Pruning dead worker: #{worker}"
        if worker.respond_to?(:unregister_worker)
          worker.unregister_worker
        else # Resque 2.x
          Registry.for(worker).unregister
        end
      end
    end
1138321
def as_pruning(self):
        
        return PruningMapping(self.__mp_reg, self.__mapped_cls, self.__de_cls,
                              self.__configurations[-1])
30362
public void prune() {
		if (children != null) {
			List<String> removeList = new ArrayList<String>();
			for (Entry<String, DepTreeNode> entry : children.entrySet()) {
				DepTreeNode child = entry.getValue();
				child.prune();
				if ((child.defineDependencies == null && child.requireDependencies == null && child.uri == null)
						&& (child.children == null || child.children.isEmpty())) {
					removeList.add(entry.getKey());
				}
			}
			for (String key : removeList) {
				children.remove(key);
			}
		}
	}
844291
def _worker_fn(samples, batchify_fn, dataset=None):
    """"""
    # pylint: disable=unused-argument
    # it is required that each worker process has to fork a new MXIndexedRecordIO handle
    # preserving dataset as global variable can save tons of overhead and is safe in new process
    global _worker_dataset
    if isinstance(samples[0], (list, tuple)):
        batch = [batchify_fn([_worker_dataset[i] for i in shard]) for shard in samples]
    else:
        batch = batchify_fn([_worker_dataset[i] for i in samples])
    buf = io.BytesIO()
    ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(batch)
    return buf.getvalue()
1181857
def run_cleanup(build_ext_cmd):
    
    if not build_ext_cmd.inplace:
        return

    bezier_dir = os.path.join("src", "bezier")
    shutil.move(os.path.join(build_ext_cmd.build_lib, LIB_DIR), bezier_dir)
    shutil.move(os.path.join(build_ext_cmd.build_lib, DLL_DIR), bezier_dir)
523804
def _thread_worker_fn(samples, batchify_fn, dataset):
    """"""
    if isinstance(samples[0], (list, tuple)):
        batch = [batchify_fn([dataset[i] for i in shard]) for shard in samples]
    else:
        batch = batchify_fn([dataset[i] for i in samples])
    return batch
396690
def _lint():
    """"""
    # Flake8 doesn't have an easy way to run checks using a Python function, so
    # just fork off another process to do it.

    # Python 3 compat:
    # - The result of subprocess call outputs are byte strings, meaning we need
    #   to pass a byte string to endswith.
    project_python_files = [filename for filename in get_project_files()
                            if filename.endswith(b'.py')]
    retcode = subprocess.call(
        ['flake8', '--max-complexity=10'] + project_python_files)
    if retcode == 0:
        print_success_message('No style errors')
    return retcode
935117
private static int runSyncProcess(
      boolean isVerbose, boolean isInheritIO, String[] cmdline,
      StringBuilder outputBuilder, File workingDirectory, Map<String, String> envs) {
    final StringBuilder builder = outputBuilder == null ? new StringBuilder() : outputBuilder;

    // Log the command for debugging
    LOG.log(Level.FINE, "Running synced process: ``{0}''''", joinString(cmdline));
    ProcessBuilder pb = getProcessBuilder(isInheritIO, cmdline, workingDirectory, envs);
    /* combine input stream and error stream into stderr because
       1. this preserves order of process's stdout/stderr message
       2. there is no need to distinguish stderr from stdout
       3. follow one basic pattern of the design of Python<~>Java I/O redirection:
          stdout contains useful messages Java program needs to propagate back, stderr
          contains all other information */
    pb.redirectErrorStream(true);

    Process process;
    try {
      process = pb.start();
    } catch (IOException e) {
      LOG.log(Level.SEVERE, "Failed to run synced process", e);
      return -1;
    }

    // Launching threads to consume combined stdout and stderr before "waitFor".
    // Otherwise, output from the "process" can exhaust the available buffer for the combined stream
    // because stream is not read while waiting for the process to complete.
    // If buffer becomes full, it can block the "process" as well,
    // preventing all progress for both the "process" and the current thread.
    Thread outputsThread = createAsyncStreamThread(process.getInputStream(), builder, isVerbose);

    try {
      outputsThread.start();
      int exitValue = process.waitFor();
      outputsThread.join();
      return exitValue;
    } catch (InterruptedException e) {
      // The current thread is interrupted, so try to interrupt reading threads and kill
      // the process to return quickly.
      outputsThread.interrupt();
      process.destroy();
      LOG.log(Level.SEVERE, "Running synced process was interrupted", e);
      // Reset the interrupt status to allow other codes noticing it.
      Thread.currentThread().interrupt();
      return -1;
    }
  }
1013194
def cli(parser):
    '''
    
    '''
    parser.add_argument('-n', '--dry-run', action='store_true', help='Print cleanup actions without running')
    opts = parser.parse_args()

    for sitedir in site.getsitepackages():
        cleanup(sitedir, execute=not opts.dry_run, verbose=opts.verbose or opts.dry_run)
795975
private synchronized void startWeakRefCleaner() {
        weakRefCleaner = new Thread(() -> {
            boolean running = true;
            while (running) {
                try {
                    // just wait, no need to get the - gc'ed object
                    weakReferenceQueue.remove();

                    // clean up the coordinateLines entries
                    final Set<String> coordinateLinesToRemove = new HashSet<>();
                    synchronized (coordinateLines) {
                        coordinateLines.forEach((k, v) -> {
                            if (null == v.get()) {
                                coordinateLinesToRemove.add(k);
                                if (logger.isTraceEnabled()) {
                                    logger.trace("need to cleanup gc'ed coordinate line {}", k);
                                }
                            }
                        });
                    }
                    // run on the JavaFX thread, as removeCoordinateLineWithId() calls methods from the WebView
                    Platform.runLater(() -> coordinateLinesToRemove.forEach(this::removeCoordinateLineWithId));

                    // clean up the MapCoordinateElement entries
                    final Set<String> mapCoordinateElementsToRemove = new HashSet<>();
                    synchronized (mapCoordinateElements) {
                        mapCoordinateElements.forEach((k, v) -> {
                            if (null == v.get()) {
                                mapCoordinateElementsToRemove.add(k);
                                if (logger.isTraceEnabled()) {
                                    logger.trace("need to cleanup gc'ed element {}", k);
                                }
                            }
                        });
                    }
                    // run on the JavaFX thread, as removeCoordinateLineWithId() calls methods from the WebView
                    Platform.runLater(
                            () -> mapCoordinateElementsToRemove.forEach(this::removeMapCoordinateElementWithId));
                } catch (InterruptedException e) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("thread interrupted");
                    }
                    running = false;
                }
            }
        });
        weakRefCleaner.setName("MapView-WeakRef-Cleaner");
        weakRefCleaner.setDaemon(true);
        weakRefCleaner.start();
    }
286133
private void prune()
	{
		if (useSoftReferences)
		{
			Iterator<Map.Entry<String, Object>> it = cache.entrySet().iterator();

			while (it.hasNext())
			{
				final Map.Entry<String, Object> entry = it.next();

				if (dereference(entry.getValue()) == null)
					it.remove();
			}
		}
	}
1191901
def clean(self):
        
        if self.cleaners:
            yield from asyncio.wait([x() for x in self.cleaners],
                                    loop=self.loop)
5980
function delThread(pid) {
    //Delete worker entry from worker

    delete workers[pid];

    //Remove pid from pid array
    var position = pids.indexOf(pid);
    if (~position) pids.splice(position, 1);

    //Reset array index
    pids = pids.filter(function(){return true;});
}
1090939
def _clean(c):
    
    if isdir(c.sphinx.target):
        rmtree(c.sphinx.target)