On Thu, Jun 05, 2025 at 10:05:51AM +0200, intrigeri wrote:
on my sid system, pdfarranger fails to start:
$ pdfarranger
Traceback (most recent call last):
File "/bin/pdfarranger", line 33, in <module>
sys.exit(load_entry_point('pdfarranger==1.11.1', 'console_scripts',
'pdfarranger')())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3/dist-packages/pdfarranger/pdfarranger.py", line 2846,
in main
PdfArranger().run(sys.argv)
~~~~~~~~~~~^^
File "/usr/lib/python3/dist-packages/pdfarranger/pdfarranger.py", line 299, in
__init__
multiprocessing.set_start_method('spawn')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/usr/lib/python3.13/multiprocessing/context.py", line 247, in
set_start_method
raise RuntimeError('context has already been set')
RuntimeError: context has already been set
zsh: exit 1 pdfarranger
In a (somewhat cleaner) sid VM, I could not initially reproduce the bug, then
after upgrading the system I could.
So I suspect the root cause is in another package.
It looks to me as though it might be due to
https://github.com/python/cpython/pull/134620, which landed on the 3.13
branch recently and would have been introduced via python3.13 3.13.4-1.
While it doesn't look as though calling get_start_method should have
this effect, the method definitions are as follows:
def set_start_method(self, method, force=False):
if self._actual_context is not None and not force:
raise RuntimeError('context has already been set')
if method is None and force:
self._actual_context = None
return
self._actual_context = self.get_context(method)
def get_start_method(self, allow_none=False):
if self._actual_context is None:
if allow_none:
return None
self._actual_context = self._default_context
return self._actual_context._name
So pdfarranger probably needs to call
multiprocessing.set_start_method('spawn') before it calls
multiprocessing.freeze_support()? Can you see if the attached patch
works (you can just apply it directly to
/usr/lib/python3/dist-packages/pdfarranger/pdfarranger.py for now - if
it works then I'll get it into the package properly)?
Thanks,
--
Colin Watson (he/him) [[email protected]]
diff --git a/pdfarranger/pdfarranger.py b/pdfarranger/pdfarranger.py
index 1f1c6a7..0637015 100644
--- a/pdfarranger/pdfarranger.py
+++ b/pdfarranger/pdfarranger.py
@@ -41,6 +41,7 @@ from urllib.request import url2pathname
from functools import lru_cache
from math import log
+multiprocessing.set_start_method('spawn')
multiprocessing.freeze_support() # Does nothing in Linux
sharedir = os.path.join(sys.prefix, 'share')
@@ -296,7 +297,6 @@ class PdfArranger(Gtk.Application):
self.vadj_percent = None
self.end_rubberbanding = False
self.disable_quit = False
- multiprocessing.set_start_method('spawn')
self.quit_flag = multiprocessing.Event()
self.layer_pos = 0.5, 0.5