Skip to content

Commit dd462f1

Browse files
committed
[GR-74148] Relax multiprocessing wait timeout upper bound
PullRequest: graalpython/4333
2 parents 3cddaba + 28ebc3d commit dd462f1

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

graalpython/com.oracle.graal.python.test/src/tests/test_multiprocessing_graalpy.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -80,7 +80,9 @@ def test_wait_timeout():
8080
res = wait(fds, timeout)
8181
delta = time.monotonic() - start
8282
assert not res
83-
assert delta < timeout * 2
83+
# The GraalPy multiprocessing wait path actively polls fake file descriptors and may
84+
# overshoot under scheduling contention.
85+
assert delta < timeout * 8
8486
assert delta > timeout / 2
8587

8688

graalpython/lib-python/3/multiprocessing/context.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ class TimeoutError(ProcessError):
2323
class AuthenticationError(ProcessError):
2424
pass
2525

26+
27+
# Begin Truffle change
28+
_graalpy_backend_futurewarned = False
29+
30+
31+
def _warn_graalpy_backend_futurewarning_once(stacklevel):
32+
import warnings
33+
global _graalpy_backend_futurewarned
34+
if not _graalpy_backend_futurewarned:
35+
warnings.warn(
36+
"The 'graalpy' multiprocessing backend is deprecated and will be removed in a future "
37+
"GraalPy release. Use the 'spawn' start method where available.",
38+
FutureWarning,
39+
stacklevel=stacklevel,
40+
)
41+
_graalpy_backend_futurewarned = True
42+
# End Truffle change
43+
2644
#
2745
# Base type for contexts. Bound methods of an instance of this type are included in __all__ of __init__.py
2846
#
@@ -215,7 +233,10 @@ def _check_available(self):
215233

216234
# Begin Truffle change
217235
def _is_graalpy(self):
218-
return isinstance(self.get_context(), GraalPyContext)
236+
is_graalpy = isinstance(self.get_context(), GraalPyContext)
237+
if is_graalpy:
238+
_warn_graalpy_backend_futurewarning_once(stacklevel=3)
239+
return is_graalpy
219240

220241
def _get_id(self):
221242
if self._is_graalpy():
@@ -321,6 +342,7 @@ class GraalPyProcess(process.BaseProcess):
321342
_start_method = 'graalpy'
322343
@staticmethod
323344
def _Popen(process_obj):
345+
_warn_graalpy_backend_futurewarning_once(stacklevel=3)
324346
from multiprocessing.popen_truffleprocess import Popen
325347
return Popen(process_obj)
326348

0 commit comments

Comments
 (0)