2020-06-08 08:23:32 +00:00
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
2020-06-05 12:42:04 +00:00
|
|
|
from tasks.check_corpora import check_corpora
|
2020-06-08 08:23:32 +00:00
|
|
|
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():
|
2020-06-08 11:52:54 +00:00
|
|
|
execute_notifications = os.environ.get('NOPAQUE_EXECUTE_NOTIFICATIONS')
|
2020-06-05 12:42:04 +00:00
|
|
|
# executing background functions
|
|
|
|
while True:
|
2020-06-08 08:23:32 +00:00
|
|
|
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.
|
2020-06-08 08:23:32 +00:00
|
|
|
# But notification status will be set nonetheless.
|
2020-06-05 12:42:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
nopaqued()
|