From d2f79a4dfd256d85f6bb5dd4abd5329a6e9e7c4c Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Mon, 3 Jun 2024 14:14:21 +0100 Subject: [PATCH] Try manually killing the process associated with port 10000. --- environment.yaml | 1 + environment_sire.yaml | 1 + tests/conftest.py | 16 ++++++++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/environment.yaml b/environment.yaml index 3866bde..4c41609 100644 --- a/environment.yaml +++ b/environment.yaml @@ -11,6 +11,7 @@ dependencies: - eigen - loguru - pip + - psutil - pybind11 - pytorch - python < 3.11 diff --git a/environment_sire.yaml b/environment_sire.yaml index 418f378..3592e2d 100644 --- a/environment_sire.yaml +++ b/environment_sire.yaml @@ -13,6 +13,7 @@ dependencies: - loguru - openmm >= 8.1 - pip + - psutil - pybind11 - pytorch - python < 3.11 diff --git a/tests/conftest.py b/tests/conftest.py index 61d0f1b..ebc8d52 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,6 @@ import os import pytest +import psutil import shlex import subprocess @@ -12,9 +13,12 @@ def wrapper(): yield - # Stop the EMLE server. - process = subprocess.run( - shlex.split("emle-stop"), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) + # Kill the EMLE server. We do this manually rather than using emle-stop + # because there is sometimes a delay in the termination of the server, + # which causes the next test # to fail. This only seems to happen when + # testing during CI. + for conn in psutil.net_connections(kind="inet"): + if conn.laddr.port == 10000: + process = psutil.Process(conn.pid) + process.terminate() + break