Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tests/python/metrics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

import unittest
from multiprocessing import Process, Queue
from multiprocessing import Process, Queue, get_start_method, get_context

from test_helpers import *

Expand Down Expand Up @@ -142,6 +142,17 @@ def test_distances_part_pickle(self):
self.assert_correct_matrix(dist_from_parts, self.threads)

def test_distances_part_parallel(self):

# On macOS and newly non-macOS POSIX systems (since Python 3.14),
# the default method has been changed to forkserver.
# The code in this module does not work with it,
# hence the explicit change to 'fork'
# See https://github.com/python/cpython/issues/125714
if get_start_method() == "forkserver":
_mp_context = get_context(method="fork")
else:
_mp_context = get_context()

def do_test(threads, nparts):
parts = satyr.DistancesPart.create(len(threads), nparts)

Expand All @@ -156,7 +167,7 @@ def compute_part(part, queue):
result_queue = Queue()
processes = []
for p in parts:
processes.append(Process(target=compute_part, args=(p, result_queue)))
processes.append(_mp_context.Process(target=compute_part, args=(p, result_queue)))
processes[-1].start()

parts = []
Expand Down