Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for subprocesses in executor jobs #954

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion tests/unittests/executor/test_executor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import time
from multiprocessing import TimeoutError
from multiprocessing import Process, TimeoutError

import pytest

Expand Down Expand Up @@ -200,6 +200,13 @@ def nested_jobs(executor):
return sum(all_results)


def job_with_subprocess():
p = Process(target=time.sleep, args=(1,))
p.start()
p.join()
return 1


@pytest.mark.parametrize("backend", [SingleExecutor])
def test_executor_is_serializable(backend):
with backend(5) as executor:
Expand Down Expand Up @@ -282,3 +289,14 @@ def test_executors_del_does_not_raise(backend):
del executor.client

del executor


@pytest.mark.parametrize("backend", backends)
def test_executor_support_subprocess(backend):
"""A subprocess can be spawn inside the process"""

with backend(5) as executor:
futures = [executor.submit(job_with_subprocess) for _ in range(10)]
all_results = executor.wait(futures)

assert sum(all_results) == 10