nopaque/daemon/nopaqued.py

30 lines
1.1 KiB
Python
Raw Normal View History

2020-06-05 12:42:04 +00:00
from tasks.check_corpora import check_corpora
from tasks.check_jobs import check_jobs
2020-06-05 12:42:04 +00:00
from tasks.notify import notify
2020-06-10 12:18:02 +00:00
from time import sleep
2020-06-08 11:52:54 +00:00
import os
2020-06-05 12:42:04 +00:00
def nopaqued():
2020-06-10 12:18:02 +00:00
NOPAQUE_EXECUTE_NOTIFICATIONS = os.environ.get('NOPAQUE_EXECUTE_NOTIFICATIONS', 'True').lower() == 'true' # noqa
threads = {'check_corpora': None, 'check_jobs': None, 'notify': None}
threads['check_corpora'] = check_corpora()
threads['check_jobs'] = check_jobs()
threads['notify'] = notify(NOPAQUE_EXECUTE_NOTIFICATIONS)
2020-06-05 12:42:04 +00:00
while True:
2020-06-10 12:18:02 +00:00
if not threads['check_corpora'].is_alive():
threads['check_corpora'] = check_corpora()
if not threads['check_jobs'].is_alive():
threads['check_jobs'] = check_jobs()
if not threads['notify'].is_alive():
threads['notify'] = notify(NOPAQUE_EXECUTE_NOTIFICATIONS)
2020-06-08 11:52:54 +00:00
# If execute_notifications True mails are sent.
# If execute_notifications False no mails are sent.
# But notification status will be set nonetheless.
2020-06-10 12:18:02 +00:00
sleep(3)
2020-06-05 12:42:04 +00:00
if __name__ == '__main__':
nopaqued()