Skip to content

Add multiple process add test #382

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

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion simvue/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def _execute_process(
)

_status_code = _result.wait()

with open(f"{runner_name}_{proc_id}.err") as err:
std_err[proc_id] = err.read()

Expand Down
27 changes: 27 additions & 0 deletions tests/refactor/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
import tempfile
import pathlib
import os
import multiprocessing


Expand Down Expand Up @@ -38,6 +39,32 @@ def test_executor_add_process(
run.close()


@pytest.mark.executor
def test_executor_multiprocess(request: pytest.FixtureRequest) -> None:
with tempfile.TemporaryDirectory() as tempd:
with simvue.Run() as run:
run.init(
"test_executor_multiprocess",
folder="/simvue_unit_testing",
tags=["simvue_client_tests", request.node.name]
)

for i in range(10):
out_file = pathlib.Path(tempd).joinpath(f"out_file_{i}.dat")
run.add_process(
f"cmd_{i}",
executable="bash",
c="for i in {0..10}; do sleep 0.5; echo $i >> "+ f"{out_file}; done"
)
time.sleep(1)
for i in range(10):
out_file = pathlib.Path(tempd).joinpath(f"out_file_{i}.dat")
assert out_file.exists()
for i in range(10):
os.remove(f"test_executor_multiprocess_cmd_{i}.err")
os.remove(f"test_executor_multiprocess_cmd_{i}.out")


@pytest.mark.executor
def test_add_process_command_assembly(request: pytest.FixtureRequest) -> None:
with tempfile.TemporaryDirectory() as tempd:
Expand Down
Loading