diff --git a/.ci/start_fluent.py b/.ci/start_fluent.py index 26650d19ddfd..2c783bceda71 100644 --- a/.ci/start_fluent.py +++ b/.ci/start_fluent.py @@ -16,26 +16,30 @@ def start_fluent_container(args): license_server = os.environ["ANSYSLMD_LICENSE_FILE"] port = os.environ["PYFLUENT_FLUENT_PORT"] - subprocess.run(["docker", "run", "--name", "fluent_server", "-d", "--rm", - "-p", f"{port}:{port}", - "-v", f"{EXAMPLES_PATH}:{EXAMPLES_PATH}", - "-e", f"ANSYSLMD_LICENSE_FILE={license_server}", - "-e", f"REMOTING_PORTS={port}/portspan=2", - "-e", "FLUENT_LAUNCHED_FROM_PYFLUENT=1", - "ghcr.io/pyansys/pyfluent", - "-g", f"-sifile={sifile}"] + args) + try: + subprocess.run(["docker", "run", "--name", "fluent_server", "-d", + "--rm", "-p", f"{port}:{port}", + "-v", f"{EXAMPLES_PATH}:{EXAMPLES_PATH}", + "-e", f"ANSYSLMD_LICENSE_FILE={license_server}", + "-e", f"REMOTING_PORTS={port}/portspan=2", + "-e", "FLUENT_LAUNCHED_FROM_PYFLUENT=1", + "ghcr.io/pyansys/pyfluent", + "-g", f"-sifile={sifile}"] + args) - sifile_last_mtime = os.stat(sifile).st_mtime - while True: - if os.stat(sifile).st_mtime > sifile_last_mtime: + sifile_last_mtime = os.stat(sifile).st_mtime + while True: + if os.stat(sifile).st_mtime > sifile_last_mtime: + time.sleep(1) + break + if timeout == 0: + break time.sleep(1) - break - if timeout == 0: - break - time.sleep(1) - timeout -= 1 - if os.path.exists(sifile): - os.remove(sifile) + timeout -= 1 + except OSError: + pass + finally: + if os.path.exists(sifile): + os.remove(sifile) if __name__ == "__main__": diff --git a/.ci/stop_fluent.py b/.ci/stop_fluent.py index ff6fa5f74358..e46c114e217d 100644 --- a/.ci/stop_fluent.py +++ b/.ci/stop_fluent.py @@ -2,7 +2,10 @@ def stop_fluent_container(): - subprocess.run(["docker", "stop", "fluent_server"]) + try: + subprocess.run(["docker", "stop", "fluent_server"]) + except OSError: + pass if __name__ == "__main__": diff --git a/doc/source/conf.py b/doc/source/conf.py index b7db6a1aafc5..577fa34ba7bd 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -106,13 +106,15 @@ def _start_or_stop_fluent_container(gallery_conf, fname, when): - if when == "before": - if fname in ["mixing_elbow_settings_api.py", - "mixing_elbow_tui_api.py"]: - args = ["3ddp", "-t4", "-meshing"] - subprocess.run([sys.executable, _START_FLUENT_FILE] + args) - elif when == "after": - subprocess.run([sys.executable, _STOP_FLUENT_FILE]) + start_instance = bool(int(os.getenv("PYFLUENT_START_INSTANCE", "1"))) + if not start_instance: + if when == "before": + if fname in ["mixing_elbow_settings_api.py", + "mixing_elbow_tui_api.py"]: + args = ["3ddp", "-t4", "-meshing"] + subprocess.run([sys.executable, _START_FLUENT_FILE] + args) + elif when == "after": + subprocess.run([sys.executable, _STOP_FLUENT_FILE]) # -- Sphinx Gallery Options ---------------------------------------------------