Periodic cleanup tasks to maintain this adapter, should be called every second.
176576
def periodic_callback(self):
        

        if self.stopped:
            return

        # Check if we should start scanning again
        if not self.scanning and len(self.connections.get_connections()) == 0:
            self._logger.info("Restarting scan for devices")
            self.start_scan(self._active_scan)
            self._logger.info("Finished restarting scan for devices")
673385
public function cleanup()
    {
        // unlock everything
        foreach ($this->locks as $lock) {
            flock($lock, LOCK_UN);
            fclose($lock);
        }

        $this->locks = [];
    }
619777
def _periodically_flush_profile_events(self):
        """"""
        # Note(rkn): This is run on a background thread in the driver. It uses
        # the raylet client. This should be ok because it doesn't read
        # from the raylet client and we have the GIL here. However,
        # if either of those things changes, then we could run into issues.
        while True:
            # Sleep for 1 second. This will be interrupted if
            # self.threads_stopped is set.
            self.threads_stopped.wait(timeout=1)

            # Exit if we received a signal that we should stop.
            if self.threads_stopped.is_set():
                return

            self.flush_profile_data()
741219
void cleanUp() {
    if (threadStarted) {
      return;
    }

    Reference<?> reference;
    while ((reference = queue.poll()) != null) {
      /*
       * This is for the benefit of phantom references. Weak and soft
       * references will have already been cleared by this point.
       */
      reference.clear();
      try {
        ((FinalizableReference) reference).finalizeReferent();
      } catch (Throwable t) {
        logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
      }
    }
  }
841795
public void autoRefresh() {
        if (!isPullRefreshEnabled) return;

        setRefreshing(true);
        new android.os.Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                callOnPullRefresh();
            }
        }, 1000);
    }
413378
private void ensureCleanStartup() {
        forceShutdown();
        ScheduledThreadPoolExecutor oldPool = pool.getAndSet(createScheduledThreadExecutor());
        oldPool.shutdownNow();
        claimedForHandoff.clear();
        workUnitsPeggedToMe.clear();
        state.set(NodeState.Fresh);
    }
1051055
def cleanup_sweep_threads():
    '''
    
    '''

    for dict_name, obj in globals().items():
        if isinstance(obj, (TimedDict,)):
            logging.info(
                'Stopping thread for TimedDict {dict_name}'.format(
                    dict_name=dict_name))
            obj.stop_sweep()
919584
private void scheduleFlushTask()
   {
      // cancel task
      if (flushTask != null)
      {
         flushTask.cancel();
      }
      // clear canceled tasks
      FLUSH_TIMER.purge();
      // new flush task, cause canceled can't be re-used
      flushTask = new TimerTask()
      {
         @Override
         public void run()
         {
            // check if volatile index should be flushed
            checkFlush();
         }
      };
      FLUSH_TIMER.schedule(flushTask, 0, 1000);
      lastFlushTime = System.currentTimeMillis();
      lastFileSystemFlushTime = System.currentTimeMillis();
   }
638209
public void cleanup() {
		long currentTime = System.currentTimeMillis();

		// remove entries which have exceeded their time to live
		cachedExecutionGraphs.values().removeIf(
			(ExecutionGraphEntry entry) -> currentTime >= entry.getTTL());
	}
222885
private synchronized void clean() {
		
		while (checkOverFlow()) {

			List<CacheObject> cacheObjectList = sort();

			if (cacheObjectList != null && cacheObjectList.size() > 0) {
				CacheObject cacheObject = (CacheObject) cacheObjectList.get(0);
				remove(cacheObject.getKey());
			}
		}
	}
863220
private void scheduleRenewalThresholdUpdateTask() {
        timer.schedule(new TimerTask() {
                           @Override
                           public void run() {
                               updateRenewalThreshold();
                           }
                       }, serverConfig.getRenewalThresholdUpdateIntervalMs(),
                serverConfig.getRenewalThresholdUpdateIntervalMs());
    }
639324
async def start(self):
        

        self._loop.add_task(self._periodic_loop, name="periodic task for %s" % self._adapter.__class__.__name__,
                            parent=self._task)

        self._adapter.add_callback('on_scan', functools.partial(_on_scan, self._loop, self))
        self._adapter.add_callback('on_report', functools.partial(_on_report, self._loop, self))
        self._adapter.add_callback('on_trace', functools.partial(_on_trace, self._loop, self))
        self._adapter.add_callback('on_disconnect', functools.partial(_on_disconnect, self._loop, self))
910526
def stop_regularly_cleanup(self, only_read=False):
        
        if hasattr(self, 'cleanup_supervisor') and self.cleanup_supervisor is not None:
            self.cleanup_supervisor.stop()
            self.logger.debug('Regularly cleanup thread %s is closed' % self.cleanup_supervisor.name)
            self.cleanup_supervisor = None
            return True
        else:
            self.logger.warning('Current not have a regularly cleanup thread is existent')
            return False
372689
def cleanup(self):
        
        if self.transport:
            self.transport.close()
            self.transport = None
        if self.task:
            self.task.cancel()
            self.task = None
104203
protected void start() {
        // if a periodic execution throws an exception, future executions are suspended,
        // this task wraps the call in a try-catch block to prevent that. Errors are still propagated.
        final Runnable resilientTask = () -> {
            try {
                run();
            } catch (final Exception e) {
                logger.error("[{}] Error during timeout-initiated flush", name, e);
            }
        };

        scheduler.scheduleAtFixedRate(resilientTask, 0, batchTimeout + salt, TimeUnit.MILLISECONDS);
    }
1357026
def cleanup(self):
		
		for task in self.__done_registry:
			task.stop()
		self.__done_registry.clear()
		self.cleanup_event().clear()
348418
public void clean() {
        Instant minAge = Instant.now().minus(storageTimeInSeconds, ChronoUnit.SECONDS);
        synchronized (messages) {
            messages.removeIf(messageRef -> Optional.ofNullable(messageRef.get())
                    .map(message -> !message.isCachedForever() && message.getCreationTimestamp().isBefore(minAge))
                    .orElse(true));
            long foreverCachedAmount = messages.stream()
                    .map(Reference::get)
                    .filter(Objects::nonNull)
                    .filter(Message::isCachedForever)
                    .count();
            messages.removeAll(messages.stream()
                                       .filter(messageRef -> Optional.ofNullable(messageRef.get())
                                               .map(message -> !message.isCachedForever())
                                               .orElse(true))
                                       .limit(Math.max(0, messages.size() - capacity - foreverCachedAmount))
                                       .collect(Collectors.toList()));
        }
    }