Skip to content

Commit

Permalink
Tests: Avoid the multiprocessing forkserver method
Browse files Browse the repository at this point in the history
  • Loading branch information
hroncok committed Dec 11, 2024
1 parent 067591d commit c458b53
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down

0 comments on commit c458b53

Please sign in to comment.