Skip to content

Commit f525228

Browse files
committed
Fix multiprocessing fork warnings (Python 3.13, Linux) by setting spawn method early
1 parent 202817f commit f525228

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

datalab/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,19 @@
1111
.. _PlotPyStack: https://github.com/PlotPyStack
1212
"""
1313

14+
import multiprocessing
1415
import os
1516

17+
# Set multiprocessing start method to 'spawn' early to avoid fork-related warnings
18+
# on Linux systems when using Qt and multithreading. This must be done before
19+
# any multiprocessing.Pool is created.
20+
try:
21+
multiprocessing.set_start_method("spawn")
22+
except RuntimeError:
23+
# This exception is raised if the method is already set (this may happen because
24+
# this module is imported more than once, e.g. when running tests)
25+
pass
26+
1627
__version__ = "0.21.0"
1728
__docurl__ = __homeurl__ = "https://datalab-platform.com/"
1829
__supporturl__ = "https://github.com/DataLab-Platform/DataLab/issues/new/choose"

0 commit comments

Comments
 (0)