def _timeout_checker(self):
"""
Runs `timeout_check` and if there are no more non-sticky
patterns in :attr:`self._patterns`, stops :attr:`scheduler`.
"""
if not self._checking_patterns:
self._checking_patterns = True
remaining_patterns = self.timeout_check()
if not remaining_patterns:
# No reason to keep the PeriodicCallback going
logging.debug("Stopping self.scheduler (no remaining patterns)")
try:
self.scheduler.stop()
except AttributeError:
# Now this is a neat trick: The way IOLoop works with its
# stack_context thingamabob the scheduler doesn't actualy end up
# inside the MultiplexPOSIXIOLoop instance inside of this
# instance of _timeout_checker() *except* inside the main
# thread. It is absolutely wacky but it works and works well :)
pass
self._checking_patterns = False
评论列表
文章目录