Skip to content

Commit 25c3f6c

Browse files
alexmalyshevmeta-codesync[bot]
authored andcommitted
Ignore warnings about fork used in multi-threaded test environment
Summary: It's just noise right now. Reviewed By: yoney Differential Revision: D116882652 fbshipit-source-id: 33f8346650662d3f3921f6fd9cd0d7e7313aa3d5
1 parent 5f1996a commit 25c3f6c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

cinderx/PythonLib/cinderx/test_support.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import tempfile
1515
import types
1616
import unittest
17+
import warnings
1718
from contextlib import contextmanager
1819
from pathlib import Path
1920
from typing import Callable, Generator, Sequence, TypeVar
@@ -352,10 +353,22 @@ def wrapper(queue: multiprocessing.Queue, *args: object) -> None:
352353
except Exception as e:
353354
queue.put(_ExceptionResult(e), timeout=SUBPROCESS_TIMEOUT_SEC)
354355

356+
@functools.wraps(func)
355357
def wrapped(*args: object) -> None:
356358
fork = multiprocessing.get_context("fork")
357359
p = fork.Process(target=wrapper, args=(queue, *args))
358-
p.start()
360+
361+
# Ignore warnings about running fork in a multi-threaded environment, they're
362+
# not helpful.
363+
with warnings.catch_warnings():
364+
warnings.filterwarnings(
365+
"ignore",
366+
category=DeprecationWarning,
367+
message=r"This process.*is multi-threaded.*",
368+
)
369+
370+
p.start()
371+
359372
value = queue.get(timeout=SUBPROCESS_TIMEOUT_SEC)
360373
p.join(timeout=SUBPROCESS_TIMEOUT_SEC)
361374
if isinstance(value, _ExceptionResult):

0 commit comments

Comments
 (0)