From c458b53a5dc2d554e88c4c353427aa1d90ccf453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 25 Nov 2024 13:57:00 +0100 Subject: [PATCH] Tests: Avoid the multiprocessing forkserver method Fixes https://bugzilla.redhat.com/2323186 --- tests/test_lock.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test_lock.py b/tests/test_lock.py index ce9806b449..d45557e95d 100644 --- a/tests/test_lock.py +++ b/tests/test_lock.py @@ -42,6 +42,15 @@ from tests.support import mock +# The tests here are not compatible with the forkserver method, +# which is the default on Python 3.14+. +# See https://github.com/python/cpython/issues/125714 +if multiprocessing.get_start_method() == 'forkserver': + mp_context = multiprocessing.get_context(method='fork') +else: + mp_context = multiprocessing.get_context() + + class ConcurrencyMixin(object): def __init__(self, lock): self.lock = lock @@ -61,11 +70,11 @@ def __init__(self, lock): self.queue = dnf.pycomp.Queue(1) -class OtherProcess(ConcurrencyMixin, multiprocessing.Process): +class OtherProcess(ConcurrencyMixin, mp_context.Process): def __init__(self, lock): ConcurrencyMixin.__init__(self, lock) - multiprocessing.Process.__init__(self) - self.queue = multiprocessing.Queue(1) + mp_context.Process.__init__(self) + self.queue = mp_context.Queue(1) TARGET = os.path.join(tests.support.USER_RUNDIR, 'unit-test.pid')