Skip to content

Commit 28ebc3d

Browse files
committed
Start warning about using the graalpy multiprocessing backend
1 parent 3f90097 commit 28ebc3d

File tree

1 file changed

+23
-1
lines changed
  • graalpython/lib-python/3/multiprocessing

1 file changed

+23
-1
lines changed

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)