Skip to content

Commit de47a89

Browse files
tpwrulestridge
authored andcommitted
fix error with Python 3.14 on Linux
Python 3.14 switches to multiprocessing start method `forkserver` on Linux, which our code is broken with due to changes in Python 3.13 and our bad habit of running code in the main module. This causes our compile/test subprocesses to die, saying `dronecan_dsdlc.py: error: the following arguments are required: namespace_dir` and ultimately failing with `ConnectionResetError: [Errno 104] Connection reset by peer`. Fix by switching back to the old default of `fork` if we are going to use the broken `forkserver`. Our code needs to be fixed in the future to not do so much in the main module as `fork` is not the recommened method, though we probably do not fall afoul of its flaws.
1 parent bd91247 commit de47a89

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dronecan_dsdlc.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
import shutil
1414
import time
1515

16+
if __name__ == '__main__':
17+
import multiprocessing
18+
19+
default_method = multiprocessing.get_all_start_methods()[0]
20+
# we are not compatible with forkserver because we trust argv to be set up
21+
# during module import, which using forkserver it is not in Python 3.13 and
22+
# later. as Python 3.14 and later make forkserver the default on Linux, we
23+
# need to switch back to the previous default of fork until we fix our code
24+
# to not run stuff on import.
25+
if default_method == "forkserver":
26+
default_method = "fork"
27+
multiprocessing.set_start_method(default_method)
28+
1629
try:
1730
import dronecan.dsdl
1831
except Exception as ex:

0 commit comments

Comments
 (0)