def heartbeat(self):
"""Heartbeat function
Every hearbeat_interval seconds, runs registered functions. This will
capture unhandled exceptions and report them.
"""
# Keep beating unless the WSGI worker is shutting down
while self.is_alive():
logger.debug('thump')
self._heartbeat_beat_once()
gevent.sleep(self.heartbeat_interval)
logger.info('App stopped, so stopping heartbeat.')
# We're at worker shutdown, so beat until all registered lifers are ok
# with us shutting down
while any([fun() for fun in _registered_lifers]):
logger.debug('thump (finishing up)')
self._heartbeat_beat_once()
# Faster beat so we can shutdown sooner
gevent.sleep(1)
logger.info('Everything completed.')
评论列表
文章目录