2022-02-02 22:17:35 +00:00
|
|
|
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()
|
2022-02-02 22:17:35 +00:00
|
|
|
logging.debug("active scheduler initialized")
|
2021-05-16 03:04:35 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def start():
|
2022-03-18 05:03:39 +00:00
|
|
|
web.ping()
|
2021-05-16 03:04:35 +00:00
|
|
|
active._scheduler.enter_recurring(60, 1, web.ping)
|
2022-02-02 22:17:35 +00:00
|
|
|
logging.debug("active scheduler started")
|
2021-05-16 03:04:35 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def stop():
|
|
|
|
active._scheduler.stop(hard_stop=True)
|
2022-02-02 22:17:35 +00:00
|
|
|
logging.debug("active scheduler stopped")
|