code: def stop(self):
          
          with self._lock:
              if self._stopped:
                  _logger.debug(u'%s is already stopped', self)
                  return
  
              self._flush_all_reports()
              self._stopped = True
              if self._run_scheduler_directly:
                  self._cleanup_if_stopped()
  
              if self._scheduler and self._scheduler.empty():
                  # if there are events scheduled, then _running will subsequently
                  # be set False by the scheduler thread.  This handles the
                  # case where there are no events, e.g because all aggreagation
                  # was disabled
                  self._running = False
              self._scheduler = None
docs: Halts processing
  
          This will lead to the reports being flushed, the caches being cleared
          and a stop to the current processing thread.