changed thread pool code again

This commit is contained in:
2019-11-14 15:05:06 +01:00
parent 6f1e01781a
commit 692649e08f

View File

@@ -6,6 +6,7 @@ from io import StringIO
import requests
from requests.auth import HTTPBasicAuth
from multiprocessing.pool import ThreadPool
from multiprocessing.context import TimeoutError
from pprint import pprint
@@ -140,17 +141,13 @@ with ThreadPool(NUM_THREADS) as pool:
results = [pool.apply_async(check_capture_agent_state, (agent,)) for agent in agents]
try:
[res.get(timeout=12) for res in results]
except TimeoutError:
logger.error("Timeout while getting capture agent state!")
except TimeoutError as e:
logger.error("Timeout while getting capture agent state! {}".format(e))
pool.close()
pool.join()
logged_events = rec_err_state_log_stream.getvalue()
if len(logged_events) > 0:
send_error_mail(logged_events, "Errors have been detected while checking recorder states!")
exit()
c = get_calender('CS 30.46 Chemie Neuer Hoersaal')
print(c.events)
print(list(c.timeline)) # chronological order
print(list(c.timeline.now()))
logger.info("DONE checking capture agents / recorders!")