Skip to content

Commit d28b52f

Browse files
committed
Makes the psutil module an optional dependency for testing.
1 parent b91d98b commit d28b52f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cuda_core/tests/memory_ipc/test_leaks.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
import gc
66
import multiprocessing as mp
77

8-
import psutil
8+
try:
9+
import psutil
10+
except ImportError:
11+
HAVE_PSUTIL = False
12+
else:
13+
HAVE_PSUTIL = True
14+
915
import pytest
1016
from cuda.core.experimental import _memory
1117
from cuda.core.experimental._utils.cuda_utils import driver
@@ -14,10 +20,12 @@
1420
NBYTES = 64
1521

1622
USING_FDS = _memory._IPC_HANDLE_TYPE == driver.CUmemAllocationHandleType.CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR
17-
skip_unless_using_fds = pytest.mark.skipif(not USING_FDS, reason="mempool allocation handle is not using fds")
23+
skip_if_unrunnable = pytest.mark.skipif(
24+
not USING_FDS or not HAVE_PSUTIL, reason="mempool allocation handle is not using fds or psutil is unavailable"
25+
)
1826

1927

20-
@skip_unless_using_fds
28+
@skip_if_unrunnable
2129
def test_alloc_handle(ipc_memory_resource):
2230
"""Check for fd leaks in get_allocation_handle."""
2331
mr = ipc_memory_resource
@@ -73,7 +81,7 @@ def __reduce__(self):
7381
raise RuntimeError("Irreducible")
7482

7583

76-
@skip_unless_using_fds
84+
@skip_if_unrunnable
7785
@pytest.mark.parametrize(
7886
"getobject",
7987
[

0 commit comments

Comments
 (0)