Cleanup all files in the cache directory to ensure that at lead newJobReqs are available
        for use.

        :param float newJobReqs: the total number of bytes of files allowed in the cache.
555880
def cleanCache(self, newJobReqs):
        
        with self._CacheState.open(self) as cacheInfo:
            # Add the new job's disk requirements to the sigmaJobDisk variable
            cacheInfo.sigmaJob += newJobReqs
            # Initialize the job state here. we use a partial in the jobSpecificFiles call so
            # that this entire thing is pickleable. Based on answer by user Nathaniel Gentile at
            # http://stackoverflow.com/questions/2600790
            assert self.jobID not in cacheInfo.jobState
            cacheInfo.jobState[self.jobID] = {
                'jobName': self.jobName,
                'jobReqs': newJobReqs,
                'jobDir': self.localTempDir,
                'jobSpecificFiles': defaultdict(partial(defaultdict,int)),
                'filesToFSIDs': defaultdict(set),
                'pid': os.getpid(),
                'deferredFunctions': []}
            # If the caching equation is balanced, do nothing.
            if cacheInfo.isBalanced():
                return None

            # List of deletable cached files.  A deletable cache file is one
            #  that is not in use by any other worker (identified by the number of symlinks to
            # the file)
            allCacheFiles = [os.path.join(self.localCacheDir, x)
                             for x in os.listdir(self.localCacheDir)
                             if not self._isHidden(x)]
            allCacheFiles = [(path, os.stat(path)) for path in allCacheFiles]
            # TODO mtime vs ctime
            deletableCacheFiles = {(path, inode.st_mtime, inode.st_size)
                                   for path, inode in allCacheFiles
                                   if inode.st_nlink == self.nlinkThreshold}

            # Sort in descending order of mtime so the first items to be popped from the list
            # are the least recently created.
            deletableCacheFiles = sorted(deletableCacheFiles, key=lambda x: (-x[1], -x[2]))
            logger.debug('CACHE: Need %s bytes for new job. Detecting an estimated %s (out of a '
                         'total %s) bytes available for running the new job. The size of the cache '
                         'is %s bytes.', newJobReqs,
                         (cacheInfo.total - (cacheInfo.cached + cacheInfo.sigmaJob - newJobReqs)),
                         cacheInfo.total, cacheInfo.cached)
            logger.debug('CACHE: Evicting files to make room for the new job.')

            # Now do the actual file removal
            totalEvicted = 0
            while not cacheInfo.isBalanced() and len(deletableCacheFiles) > 0:
                cachedFile, fileCreateTime, cachedFileSize = deletableCacheFiles.pop()
                os.remove(cachedFile)
                cacheInfo.cached -= cachedFileSize if self.nlinkThreshold != 2 else 0
                totalEvicted += cachedFileSize
                assert cacheInfo.cached >= 0
                logger.debug('CACHE: Evicted  file with ID \'%s\' (%s bytes)' %
                             (self.decodedFileID(cachedFile), cachedFileSize))
            logger.debug('CACHE: Evicted a total of %s bytes. Available space is now %s bytes.',
                         totalEvicted,
                         (cacheInfo.total - (cacheInfo.cached + cacheInfo.sigmaJob - newJobReqs)))
            if not cacheInfo.isBalanced():
                raise CacheUnbalancedError()
14168
def _default_cleanup(self):
        
        if not self.inplace:
            return

        shutil.move(
            os.path.join(self.build_lib, "bezier", "lib"),
            os.path.join("src", "bezier"),
        )
882573
private void cleanJobDirectory() {
    try {
      FileSystem jobfs = jobDirectory.getFileSystem(conf);
      jobfs.delete(jobDirectory, true);
    } catch(IOException ioe) {
      LOG.warn("Unable to clean tmp directory " + jobDirectory, ioe);
    }
  }
885607
def cleanup(dest, tardir, counterfile):
    """"""
    thefiles = Queue()
    # dest directory files
    queue_files(dest, thefiles)
    # tar directory files
    queue_files(tardir, thefiles)
    while not thefiles.empty():
        d_file = thefiles.get()
        info("Deleting file: %s" % d_file)
        os.unlink(d_file)
    if os.path.exists(counterfile):
        info("Deleting the counter file %s" % counterfile)
        os.unlink(counterfile)
267585
def clean():
    
    for queue in MyQueue.collection().instances():
        queue.delete()
    for job in MyJob.collection().instances():
        job.delete()
    for person in Person.collection().instances():
        person.delete()
158900
def cleanup(self):
        
        task = self.task

        # get job ids from submission data
        job_ids = [
            d["job_id"] for d in self.submission_data.jobs.values()
            if d["job_id"] not in (self.submission_data.dummy_job_id, None)
        ]
        if not job_ids:
            return

        # cleanup jobs
        task.publish_message("going to cleanup {} jobs".format(len(job_ids)))
        errors = self.job_manager.cleanup_batch(job_ids)

        # print errors
        if errors:
            print("{} error(s) occured while cleaning up {} job(s) of task {}:".format(
                len(errors), len(job_ids), task.task_id))
            tmpl = "    {}"
            for i, err in enumerate(errors):
                print(tmpl.format(err))
                if i + 1 >= self.show_errors:
                    remaining = len(errors) - self.show_errors
                    if remaining > 0:
                        print("    ... and {} more".format(remaining))
                    break
1236743
def _cleanup(self):
        """"""
        for filename in os.listdir(self._storage_dir):
            file_path = path.join(self._storage_dir, filename)
            file_stat = os.stat(file_path)
            evaluate = max(file_stat.st_ctime, file_stat.st_mtime)
            if evaluate + self._duration < time.time():
                LOGGER.debug('Removing stale file: %s', file_path)
                os.unlink(file_path)
657003
private void cleanUpSource() {
		SoundStore store = SoundStore.get();
		
		AL10.alSourceStop(store.getSource(0));
		IntBuffer buffer = BufferUtils.createIntBuffer(1);
		int queued = AL10.alGetSourcei(store.getSource(0), AL10.AL_BUFFERS_QUEUED);
		
		while (queued > 0)
		{
			AL10.alSourceUnqueueBuffers(store.getSource(0), buffer);
			queued--;
		}
		
		AL10.alSourcei(store.getSource(0), AL10.AL_BUFFER, 0);
	}
1193881
def obsolete_files
      out = (existing_files - new_files - new_dirs + replaced_files).to_a
      Jekyll::Hooks.trigger :clean, :on_obsolete, out
      out
    end
1058773
def cleanup_dead_jobs():
    
    from .models import WooeyJob

    # Get active tasks from Celery
    inspect = celery_app.control.inspect()
    active_tasks = {task['id'] for worker, tasks in six.iteritems(inspect.active()) for task in tasks}

    # find jobs that are marked as running but not present in celery's active tasks
    active_jobs = WooeyJob.objects.filter(status=WooeyJob.RUNNING)
    to_disable = set()
    for job in active_jobs:
        if job.celery_id not in active_tasks:
            to_disable.add(job.pk)

    WooeyJob.objects.filter(pk__in=to_disable).update(status=WooeyJob.FAILED)
797132
def clear_cache_for(*paths)
      return unless Lacquer.configuration.enable_cache
      case Lacquer.configuration.job_backend
      when :delayed_job
        require 'lacquer/delayed_job_job'
        Delayed::Job.enqueue(Lacquer::DelayedJobJob.new(paths))
      when :resque
        require 'lacquer/resque_job'
        Resque.enqueue(Lacquer::ResqueJob, paths)
      when :sidekiq
        require 'lacquer/sidekiq_worker'
        Lacquer::SidekiqWorker.perform_async(paths)
      when :none
        Varnish.new.purge(*paths)
      end
    end
1356342
def cleanup_releases(limit=5):
    

    init_tasks()

    max_versions = limit + 1

    env.run("ls -dt %s/*/ | tail -n +%s | xargs rm -rf" % (
        paths.get_releases_path(),
        max_versions)
    )
544196
public function clean() {
		if (!Configure::read('Queue.cleanuptimeout')) {
			$this->abort('You disabled cleanuptimout in config. Aborting.');
		}

		$this->out('Deleting old jobs, that have finished before ' . date('Y-m-d H:i:s', time() - (int)Configure::read('Queue.cleanuptimeout')));
		$this->QueuedJobs->cleanOldJobs();
		$this->QueueProcesses->cleanEndedProcesses();
	}
435800
public function cleanUpGarbage()
    {
        $cacheFilesExpire = time() - $this->getCacheLifetime() * 3600 * 24;

        // relies on templates sorting order being related to their modification dates
        $upperLimit = $this->getPhpCodeDestination() . $this->getFunctionNamePrefix($cacheFilesExpire) . '_';
        $lowerLimit = $this->getPhpCodeDestination() . $this->getFunctionNamePrefix(0);

        // second * gets phptal:cache
        $cacheFiles = glob($this->getPhpCodeDestination() . 'tpl_????????_*.' . $this->getPhpCodeExtension() . '*');

        if ($cacheFiles) {
            foreach ($cacheFiles as $index => $file) {

                // comparison here skips filenames that are certainly too new
                if (strcmp($file, $upperLimit) <= 0 || substr($file, 0, strlen($lowerLimit)) === $lowerLimit) {
                    $time = filemtime($file);
                    if ($time && $time < $cacheFilesExpire) {
                        @unlink($file);
                    }
                }
            }
        }
    }
21421
private void deleteNonShuffleFiles(String[] dirs) {
    FilenameFilter filter = new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        // Don't delete shuffle data or shuffle index files.
        return !name.endsWith(".index") && !name.endsWith(".data");
      }
    };

    for (String localDir : dirs) {
      try {
        JavaUtils.deleteRecursively(new File(localDir), filter);
        logger.debug("Successfully cleaned up non-shuffle files in directory: {}", localDir);
      } catch (Exception e) {
        logger.error("Failed to delete non-shuffle files in directory: " + localDir, e);
      }
    }
  }
1075640
def _cacheAllJobs(self):
        
        logger.debug('Caching all jobs in job store')
        self._jobCache = {jobGraph.jobStoreID: jobGraph for jobGraph in self._jobStore.jobs()}
        logger.debug('{} jobs downloaded.'.format(len(self._jobCache)))
1208320
def __cleanup(self):
        
# TODO: Test this.
        with self.__class__.__locker:

            while self.__read_buffer_index > 0:
                del self.__buffers[0]
                self.__read_buffer_index -= 1