nopaque/daemon/nopaqued.py

27 lines
880 B
Python
Raw Normal View History

from concurrent.futures import ThreadPoolExecutor
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-08 11:52:54 +00:00
import os
2020-06-05 12:42:04 +00:00
2020-06-05 13:17:37 +00:00
# TODO: Check if thread is still alive and execute next thread after that
2020-06-05 13:25:16 +00:00
# TODO: Check line length
2020-06-05 13:17:37 +00:00
2020-06-05 12:42:04 +00:00
def nopaqued():
execute_notifications = bool(os.environ.get('NOPAQUE_EXECUTE_NOTIFICATIONS', True)) # noqa
2020-06-05 12:42:04 +00:00
# executing background functions
while True:
with ThreadPoolExecutor(max_workers=3) as executor:
executor.submit(check_jobs)
executor.submit(check_corpora)
2020-06-08 11:52:54 +00:00
executor.submit(notify, execute_notifications)
# If execute_notifications True mails are sent.
# If execute_notifications False no mails are sent.
# But notification status will be set nonetheless.
2020-06-05 12:42:04 +00:00
if __name__ == '__main__':
nopaqued()