diff --git a/simvue/executor.py b/simvue/executor.py index ff8be2fc..979d1b48 100644 --- a/simvue/executor.py +++ b/simvue/executor.py @@ -10,7 +10,6 @@ import logging import multiprocessing.synchronize -import sys import threading import os import shutil @@ -208,8 +207,6 @@ def callback_function(status_code: int, std_out: str, std_err: str) -> None: ... ``` - Note `completion_trigger` is not supported on Windows operating systems. - Parameters ---------- identifier : str @@ -230,19 +227,13 @@ def callback_function(status_code: int, std_out: str, std_err: str) -> None: completion_callback : typing.Callable | None, optional callback to run when process terminates completion_trigger : threading.Event | None, optional - this trigger event is set when the processes completes (not supported on Windows) + this trigger event is set when the processes completes """ pos_args = list(args) if not self._runner.name: raise RuntimeError("Cannot add process, expected Run instance to have name") - if sys.platform == "win32" and completion_trigger: - logger.warning( - "Completion trigger for 'add_process' may fail on Windows " - "due to function pickling restrictions" - ) - # To check the executable provided by the user exists combine with environment # PATH variable if exists, if not provided use the current environment _session_path: str | None = (os.environ.copy() | (env or {})).get("PATH", None) diff --git a/simvue/run.py b/simvue/run.py index ca17edb7..36fa9384 100644 --- a/simvue/run.py +++ b/simvue/run.py @@ -25,7 +25,6 @@ import time import types import functools -import platform import typing import uuid import numpy @@ -876,8 +875,6 @@ def add_process( def callback_function(status_code: int, std_out: str, std_err: str) -> None: ... ``` - Note `completion_callback` is not supported on Windows operating systems. - Alternatively you can use `completion_trigger` to create a multiprocessing event which will be set when the process has completed. @@ -897,7 +894,7 @@ def callback_function(status_code: int, std_out: str, std_err: str) -> None: ... the input file to run, note this only work if the input file is not an option, if this is the case you should provide it as such and perform the upload manually, by default None completion_callback : typing.Callable | None, optional - callback to run when process terminates (not supported on Windows) + callback to run when process terminates completion_trigger : threading.Event | None, optional this trigger event is set when the processes completes env : dict[str, str], optional @@ -941,12 +938,6 @@ def callback_function(status_code: int, std_out: str, std_err: str) -> None: ... + "use an instance of 'threading.Event' instead." ) - if platform.system() == "Windows" and completion_trigger: - raise RuntimeError( - "Use of 'completion_trigger' on Windows based operating systems is unsupported " - "due to function pickling restrictions for multiprocessing" - ) - if isinstance(executable, pathlib.Path) and not executable.is_file(): raise FileNotFoundError(f"Executable '{executable}' is not a valid file") diff --git a/tests/functional/test_executor.py b/tests/functional/test_executor.py index 375dfe98..2453f34e 100644 --- a/tests/functional/test_executor.py +++ b/tests/functional/test_executor.py @@ -58,9 +58,8 @@ def completion_callback(*_, trigger=trigger, **__): @pytest.mark.executor -@pytest.mark.unix def test_executor_multiprocess(request: pytest.FixtureRequest) -> None: - triggers: dict[int, multiprocessing.synchronize.Event] = {} + triggers: dict[int, threading.Event] = {} callbacks: dict[int, typing.Callable] = {} events: dict[int, bool] = {} folder_id = f"{uuid.uuid4()}".split("-")[0] @@ -180,7 +179,6 @@ def completion_callback(*_, success: dict[str, bool]=success, **__): folder.delete(recursive=True, delete_runs=True) @pytest.mark.executor -@pytest.mark.unix def test_completion_trigger_set(request: pytest.FixtureRequest) -> None: trigger = threading.Event() folder_id = f"{uuid.uuid4()}".split("-")[0]