Note that if you don't call this before your application exits, there
may be some records still left on the queue, which won't be processed.
"""
- self.enqueue_sentinel()
- self._thread.join()
- self._thread = None
+ if self._thread: # see gh-114706 - allow calling this more than once
+ self.enqueue_sentinel()
+ self._thread.join()
+ self._thread = None
self.que_logger.critical(self.next_message())
finally:
listener.stop()
+ listener.stop() # gh-114706 - ensure no crash if called again
self.assertTrue(handler.matches(levelno=logging.WARNING, message='1'))
self.assertTrue(handler.matches(levelno=logging.ERROR, message='2'))
self.assertTrue(handler.matches(levelno=logging.CRITICAL, message='3'))