changed thread pool code again
This commit is contained in:
@@ -6,6 +6,7 @@ from io import StringIO
|
|||||||
import requests
|
import requests
|
||||||
from requests.auth import HTTPBasicAuth
|
from requests.auth import HTTPBasicAuth
|
||||||
from multiprocessing.pool import ThreadPool
|
from multiprocessing.pool import ThreadPool
|
||||||
|
from multiprocessing.context import TimeoutError
|
||||||
|
|
||||||
from pprint import pprint
|
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]
|
results = [pool.apply_async(check_capture_agent_state, (agent,)) for agent in agents]
|
||||||
try:
|
try:
|
||||||
[res.get(timeout=12) for res in results]
|
[res.get(timeout=12) for res in results]
|
||||||
except TimeoutError:
|
except TimeoutError as e:
|
||||||
logger.error("Timeout while getting capture agent state!")
|
logger.error("Timeout while getting capture agent state! {}".format(e))
|
||||||
|
|
||||||
pool.close()
|
pool.close()
|
||||||
pool.join()
|
pool.join()
|
||||||
logged_events = rec_err_state_log_stream.getvalue()
|
logged_events = rec_err_state_log_stream.getvalue()
|
||||||
if len(logged_events) > 0:
|
if len(logged_events) > 0:
|
||||||
send_error_mail(logged_events, "Errors have been detected while checking recorder states!")
|
send_error_mail(logged_events, "Errors have been detected while checking recorder states!")
|
||||||
exit()
|
|
||||||
|
|
||||||
c = get_calender('CS 30.46 Chemie Neuer Hoersaal')
|
logger.info("DONE checking capture agents / recorders!")
|
||||||
print(c.events)
|
|
||||||
print(list(c.timeline)) # chronological order
|
|
||||||
print(list(c.timeline.now()))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user