fishyboteso/fishy/helper/active_poll.py

30 lines
681 B
Python
Raw Normal View History

import logging
2021-05-16 03:04:35 +00:00
from event_scheduler import EventScheduler
from fishy.web import web
# noinspection PyPep8Naming
class active:
_scheduler: EventScheduler = None
@staticmethod
def init():
if active._scheduler:
return
active._scheduler = EventScheduler()
active._scheduler.start()
logging.debug("active scheduler initialized")
2021-05-16 03:04:35 +00:00
@staticmethod
def start():
web.ping()
2021-05-16 03:04:35 +00:00
active._scheduler.enter_recurring(60, 1, web.ping)
logging.debug("active scheduler started")
2021-05-16 03:04:35 +00:00
@staticmethod
def stop():
active._scheduler.stop(hard_stop=True)
logging.debug("active scheduler stopped")