Fixed failing concurrency tests.

pull/2772/head
derekpierre 2021-08-18 09:17:09 -04:00
parent e513e67d0a
commit aa8df5ea2a
1 changed files with 10 additions and 6 deletions

View File

@ -16,8 +16,9 @@
"""
import random
import re
import time
from typing import Iterable, Tuple, List, Callable
from typing import Iterable, Tuple
import pytest
@ -157,12 +158,14 @@ def test_wait_for_successes_out_of_values(join_worker_pool):
message = str(exc_info.value)
assert "Execution stopped before completion - not enough available values"
# We had 20 workers set up to fail
assert "20 total failures recorded" in message
assert "20 failures recorded" in message
# This will be the last line in the displayed traceback;
# That's where the worker actually failed.
assert 'raise Exception(f"Worker for {value} failed")' in message
# That's where the worker actually failed. (Worker for {value} failed)
assert re.search('for example, Worker for .* failed', message)
def test_wait_for_successes_timed_out(join_worker_pool):
@ -179,7 +182,8 @@ def test_wait_for_successes_timed_out(join_worker_pool):
seed=123)
factory = AllAtOnceFactory(list(outcomes))
pool = WorkerPool(worker, factory, target_successes=10, timeout=1, threadpool_size=30)
timeout = 1
pool = WorkerPool(worker, factory, target_successes=10, timeout=timeout, threadpool_size=30)
join_worker_pool(pool)
t_start = time.monotonic()
@ -194,7 +198,7 @@ def test_wait_for_successes_timed_out(join_worker_pool):
message = str(exc_info.value)
# None of the workers actually failed, they just timed out
assert "0 total failures recorded" in message
assert f"Execution timed out after {timeout}s" == message
def test_join(join_worker_pool):