Skip to content

Commit 8cd6f67

Browse files
committed
Fix tests.
1 parent 785101e commit 8cd6f67

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

CHANGES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ chronological order. Releases follow [semantic versioning](https://semver.org/)
55
releases are available on [PyPI](https://pypi.org/project/pytask-parallel) and
66
[Anaconda.org](https://anaconda.org/conda-forge/pytask-parallel).
77

8-
## 0.2.0 - 2022-xx-xx
8+
## 0.2.1 - 2022-08-xx
9+
10+
- {pull}`43` adds docformatter.
11+
- {pull}`44` allows to capture warnings from subprocesses. Fixes {issue}`41`.
12+
13+
## 0.2.0 - 2022-04-15
914

1015
- {pull}`31` adds types to the package.
1116
- {pull}`36` adds a test for <https://github.com/pytask-dev/pytask/issues/216>.

src/pytask_parallel/execute.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def pytask_execute_task(session: Session, task: Task) -> Future[Any] | None:
280280

281281
def _mock_processes_for_threads(
282282
func: Callable[..., Any], **kwargs: Any
283-
) -> tuple[list[Any], None]:
283+
) -> tuple[list[Any], tuple[type[BaseException], BaseException, TracebackType] | None]:
284284
"""Mock execution function such that it returns the same as for processes.
285285
286286
The function for processes returns ``warning_reports`` and an ``exception``. With
@@ -289,8 +289,13 @@ def _mock_processes_for_threads(
289289
290290
"""
291291
__tracebackhide__ = True
292-
func(**kwargs)
293-
return [], None
292+
try:
293+
func(**kwargs)
294+
except Exception:
295+
exc_info = sys.exc_info()
296+
else:
297+
exc_info = None
298+
return [], exc_info
294299

295300

296301
def _create_kwargs_for_task(task: Task) -> dict[Any, Any]:

tests/test_execute.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,11 @@ def task_example(produces):
294294

295295

296296
@pytest.mark.end_to_end
297-
@pytest.mark.parametrize("parallel_backend", PARALLEL_BACKENDS)
297+
@pytest.mark.parametrize(
298+
"parallel_backend",
299+
# Capturing warnings is not thread-safe.
300+
[backend for backend in PARALLEL_BACKENDS if backend != "threads"],
301+
)
298302
def test_collect_warnings_from_parallelized_tasks(runner, tmp_path, parallel_backend):
299303
source = """
300304
import pytask

0 commit comments

Comments
 (0)