app: Fixes startup issue on newer versions of python (>=3.14)#116
app: Fixes startup issue on newer versions of python (>=3.14)#116tmagik wants to merge 1 commit intodronecan:masterfrom
Conversation
There was a problem hiding this comment.
Hi @tmagik - thanks for this PR.
I can see at some point after python 3.12.2 and 3.14.x the function get_start_method starts returning forkserver instead of None (at least on my ubuntu machine).
I've tested this change on both, it works as i would expect.
I can try help get this merged as its own changeset, but could you update:
- Rename the PR to something more in line with what you've changed - in this case, fix main from (re)setting the multiprocessing start method.
- Drop the additional commits (I understand you may be using them but they've made your PR dependent on those changes)
This is more of a conditional approval at this stage.
Thanks
|
I'm happy to help get the fix spawn changed for newer versions of python. We'll need to rebase this and drop the pkg_resource changes though. |
|
Dependent on #115 |
9dfc81a to
828080b
Compare
|
@tmagik i've rebased this on the latest |
|
Alright, so this is the difference: # Python 3.10.12
sys.version='3.10.12 (main, Mar 3 2026, 11:56:32) [GCC 11.4.0]'
multiprocessing.get_start_method(allow_none=True)=None
multiprocessing.get_start_method(True)=None
# Python 3.13.9
sys.version='3.13.9 (main, Oct 28 2025, 12:10:42) [Clang 20.1.4 ]'
multiprocessing.get_start_method(allow_none=True)='fork'
multiprocessing.get_start_method(True)='fork'
Traceback (most recent call last):
File "/home/USER/Workspace/gui_tool/bin/dronecan_gui_tool", line 60, in <module>
from dronecan_gui_tool.main import main
File "/home/USER/Workspace/gui_tool/dronecan_gui_tool/main.py", line 77, in <module>
multiprocessing.set_start_method('spawn')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/home/USER/.local/share/uv/python/cpython-3.13.9-linux-x86_64-gnu/lib/python3.13/multiprocessing/context.py", line 247, in set_start_method
raise RuntimeError('context has already been set')
RuntimeError: context has already been setIgnore the line numbers, since I have additional debugging in there - but the error is there - newer versions of python have multiprocessing start method to be I think it may be sufficient to start multiprocessing if it is not set, but if it is set, then continue without attempting to restart it. |
This fix suggested by Gemini resolves an error that occurs on some newer versions of python (specifically the one in Debian 13)
828080b to
ca11a8e
Compare
Also need to double check this doesn't break other Operating Systems.
Need to ensure that the behaviour of fork doesn't break anything in the rest of the project that uses threads and assumed spawn.
|
Tested on MacOS (arm) and Linux, and everything seems to work correctly. |
There was a problem hiding this comment.
Revisiting this again - I've tested this with uv and python v3.14.0.
Testing steps:
uv venv --python 3.14.0
python bin/dronecan_gui_toolWithout these changes, I have the following error:
Running from the source directory
2026-05-07 11:43:20,659 INFO dronecan_gui_tool.main Spawned
Traceback (most recent call last):
File "/home/USERNAME/Workspace/gui_tool/bin/dronecan_gui_tool", line 60, in <module>
from dronecan_gui_tool.main import main
File "/home/USERNAME/Workspace/gui_tool/dronecan_gui_tool/main.py", line 73, in <module>
multiprocessing.set_start_method('spawn')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/home/USERNAME/.local/share/uv/python/cpython-3.14.0-linux-x86_64-gnu/lib/python3.14/multiprocessing/context.py", line 247, in set_start_method
raise RuntimeError('context has already been set')
RuntimeError: context has already been setWith these changes, I progress into the application - and it starts running as I expect.
I'll also note that when running with python 3.10.2, I get the same behaviour whether this patch is applied or not - the application progresses as normal.
I'm happy to mark this as approved, and try get this merged.
This adds to #115 and fixes a startup issue on Debian 13 (and probably recent fedora as well)