changed thread pool code again
This commit is contained in:
@@ -134,10 +134,14 @@ logger.info("Got {} capture agents that will be checked...".format(len(agents)))
|
||||
# pool = ThreadPool(5)
|
||||
# pool.map(check_capture_agent_state, agents)
|
||||
|
||||
with ThreadPool(5) as pool:
|
||||
for agent in agents:
|
||||
pool.apply_async(check_capture_agent_state, agent).get(timeout=10) # start single threads and enforce timeout
|
||||
NUM_THREADS = 5
|
||||
|
||||
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!")
|
||||
|
||||
pool.close()
|
||||
pool.join()
|
||||
|
||||
Reference in New Issue
Block a user