Fix hanging bug by adding manager

This commit is contained in:
Andras Schmelczer 2022-07-03 16:01:52 +02:00
parent ad1b2a20ef
commit 2f4d203446
10 changed files with 40 additions and 30 deletions

View file

@ -2,7 +2,7 @@ import unittest
import pytest
from src.great_ai.utilities import parallel_map
from src.great_ai.utilities import WorkerException, parallel_map
COUNT = int(1e5) + 3
@ -91,10 +91,10 @@ class TestParallelMap(unittest.TestCase):
def oh_no(_):
raise ValueError("hi")
with pytest.raises(ValueError):
with pytest.raises(WorkerException):
list(parallel_map(oh_no, range(COUNT), concurrency=2))
with pytest.raises(ValueError):
with pytest.raises(WorkerException):
list(parallel_map(oh_no, range(COUNT), concurrency=1))
def test_ignore_worker_process_exception(self) -> None:

View file

@ -2,7 +2,7 @@ import unittest
import pytest
from src.great_ai.utilities import threaded_parallel_map
from src.great_ai.utilities import WorkerException, threaded_parallel_map
COUNT = int(1e5) + 3
@ -91,10 +91,10 @@ class TestParallelMap(unittest.TestCase):
def oh_no(_):
raise ValueError("hi")
with pytest.raises(ValueError):
with pytest.raises(WorkerException):
list(threaded_parallel_map(oh_no, range(COUNT), concurrency=2))
with pytest.raises(ValueError):
with pytest.raises(WorkerException):
list(threaded_parallel_map(oh_no, range(COUNT), concurrency=1))
def test_ignore_worker_worker_exception(self) -> None: