code: def shutdown(self):
          
          logger.debug('Waiting for stats and logging collator thread to finish ...')
          startTime = time.time()
          self._stop.set()
          self._worker.join()
          logger.debug('... finished collating stats and logs. Took %s seconds', time.time() - startTime)
docs: Finish up the stats/logging aggregation thread