public inbox for buildroot@busybox.net
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support/testing/run-tests: unbreak on Debian testing/unstable
@ 2026-03-01 13:45 Peter Korsgaard
  2026-03-02 12:21 ` Peter Korsgaard
  2026-03-06 19:53 ` Thomas Perale via buildroot
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Korsgaard @ 2026-03-01 13:45 UTC (permalink / raw)
  To: buildroot, Jimmy Durand Wesolowski, Fiona Klute; +Cc: Ricardo Martincoski

Commit 3d2141bcee("support/testing/run-tests: specify multiprocessing
method") added a call to multiprocessing.set_start_method('fork') as a
workaround for python 3.14, which changed the default start method to
forkserver - Which is incompatible with the nose2 setup.

multiprocessing.set_start_method() is only supposed to be called a maximum
of 1 time per process and throws a RuntimeError if called more than that
(even with the same arguments):

>>> import multiprocessing
>>> multiprocessing.set_start_method('fork')
>>> multiprocessing.set_start_method('fork')
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    multiprocessing.set_start_method('fork')
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/multiprocessing/context.py", line 247, in set_start_method
    raise RuntimeError('context has already been set')

Debian included a similar patch in python3-nose2 0.51.1-2 (currently in
testing/unstable) which adds its own call to set_start_method():

https://salsa.debian.org/python-team/packages/nose2/-/blob/debian/0.15.1-2/debian/patches/0004-plugins-mp-set-context-to-fork-for-Python-3.14-mp-AP.patch?ref_type=tags

Which comes from:
https://github.com/nose-devs/nose2/pull/644

As discussed in the upstream PR, this is not a correct fix is wrong and
breaks various use cases.  An issue has been opened to get this fixed in the
Debian packaging at:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1129350

But until that is done, rework the patch to:

- Only override set_start_method() if needed to limit impact
- Monkey patch set_start_method() so additional calls are ignored

To unbreak run-test on affected Debian systems and add some documentation to
make it clear why this is done.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
 support/testing/run-tests | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/support/testing/run-tests b/support/testing/run-tests
index 1c4d2b4a85..2bbe7b140f 100755
--- a/support/testing/run-tests
+++ b/support/testing/run-tests
@@ -142,5 +142,15 @@ def main():
 
 
 if __name__ == "__main__":
-    multiprocessing.set_start_method("fork")
+    # python 3.14 changed default start method from fork to
+    # fork-server, which is not compatible with the nose2 setup
+    if multiprocessing.get_start_method() != 'fork':
+        multiprocessing.set_start_method("fork")
+        # set_start_method throws a RuntimeError if called more than
+        # once.
+        # Debian python3-nose2 0.15.1-2 includes a patch adding
+        # another set_start_method() call, so monkey patch it out to
+        # get rid of this
+        multiprocessing.set_start_method = lambda *args: None
+
     sys.exit(main())
-- 
2.47.3

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH] support/testing/run-tests: unbreak on Debian testing/unstable
  2026-03-01 13:45 [Buildroot] [PATCH] support/testing/run-tests: unbreak on Debian testing/unstable Peter Korsgaard
@ 2026-03-02 12:21 ` Peter Korsgaard
  2026-03-06 19:53 ` Thomas Perale via buildroot
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2026-03-02 12:21 UTC (permalink / raw)
  To: buildroot; +Cc: Jimmy Durand Wesolowski, Fiona Klute, Ricardo Martincoski

>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:

 > Commit 3d2141bcee("support/testing/run-tests: specify multiprocessing
 > method") added a call to multiprocessing.set_start_method('fork') as a
 > workaround for python 3.14, which changed the default start method to
 > forkserver - Which is incompatible with the nose2 setup.

 > multiprocessing.set_start_method() is only supposed to be called a maximum
 > of 1 time per process and throws a RuntimeError if called more than that
 > (even with the same arguments):

 >>>> import multiprocessing
 >>>> multiprocessing.set_start_method('fork')
 >>>> multiprocessing.set_start_method('fork')
 > Traceback (most recent call last):
 >   File "<python-input-2>", line 1, in <module>
 >     multiprocessing.set_start_method('fork')
 >     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
 >   File "/usr/lib/python3.13/multiprocessing/context.py", line 247, in set_start_method
 >     raise RuntimeError('context has already been set')

 > Debian included a similar patch in python3-nose2 0.51.1-2 (currently in
 > testing/unstable) which adds its own call to set_start_method():

 > https://salsa.debian.org/python-team/packages/nose2/-/blob/debian/0.15.1-2/debian/patches/0004-plugins-mp-set-context-to-fork-for-Python-3.14-mp-AP.patch?ref_type=tags

 > Which comes from:
 > https://github.com/nose-devs/nose2/pull/644

 > As discussed in the upstream PR, this is not a correct fix is wrong and
 > breaks various use cases.  An issue has been opened to get this fixed in the
 > Debian packaging at:

 > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1129350

 > But until that is done, rework the patch to:

 > - Only override set_start_method() if needed to limit impact
 > - Monkey patch set_start_method() so additional calls are ignored

 > To unbreak run-test on affected Debian systems and add some documentation to
 > make it clear why this is done.

 > Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

Committed after changing the logic to use the optional allow_none /
force arguments as pointed out by Julien, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH] support/testing/run-tests: unbreak on Debian testing/unstable
  2026-03-01 13:45 [Buildroot] [PATCH] support/testing/run-tests: unbreak on Debian testing/unstable Peter Korsgaard
  2026-03-02 12:21 ` Peter Korsgaard
@ 2026-03-06 19:53 ` Thomas Perale via buildroot
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Perale via buildroot @ 2026-03-06 19:53 UTC (permalink / raw)
  To: Peter Korsgaard
  Cc: Thomas Perale, buildroot, Jimmy Durand Wesolowski, Fiona Klute

In reply of:
> Commit 3d2141bcee("support/testing/run-tests: specify multiprocessing
> method") added a call to multiprocessing.set_start_method('fork') as a
> workaround for python 3.14, which changed the default start method to
> forkserver - Which is incompatible with the nose2 setup.
> 
> multiprocessing.set_start_method() is only supposed to be called a maximum
> of 1 time per process and throws a RuntimeError if called more than that
> (even with the same arguments):
> 
> >>> import multiprocessing
> >>> multiprocessing.set_start_method('fork')
> >>> multiprocessing.set_start_method('fork')
> Traceback (most recent call last):
>   File "<python-input-2>", line 1, in <module>
>     multiprocessing.set_start_method('fork')
>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
>   File "/usr/lib/python3.13/multiprocessing/context.py", line 247, in set_start_method
>     raise RuntimeError('context has already been set')
> 
> Debian included a similar patch in python3-nose2 0.51.1-2 (currently in
> testing/unstable) which adds its own call to set_start_method():
> 
> https://salsa.debian.org/python-team/packages/nose2/-/blob/debian/0.15.1-2/debian/patches/0004-plugins-mp-set-context-to-fork-for-Python-3.14-mp-AP.patch?ref_type=tags
> 
> Which comes from:
> https://github.com/nose-devs/nose2/pull/644
> 
> As discussed in the upstream PR, this is not a correct fix is wrong and
> breaks various use cases.  An issue has been opened to get this fixed in the
> Debian packaging at:
> 
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1129350
> 
> But until that is done, rework the patch to:
> 
> - Only override set_start_method() if needed to limit impact
> - Monkey patch set_start_method() so additional calls are ignored
> 
> To unbreak run-test on affected Debian systems and add some documentation to
> make it clear why this is done.
> 
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

Applied to 2025.02.x & 2025.11.x. Thanks

> ---
>  support/testing/run-tests | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/support/testing/run-tests b/support/testing/run-tests
> index 1c4d2b4a85..2bbe7b140f 100755
> --- a/support/testing/run-tests
> +++ b/support/testing/run-tests
> @@ -142,5 +142,15 @@ def main():
>  
>  
>  if __name__ == "__main__":
> -    multiprocessing.set_start_method("fork")
> +    # python 3.14 changed default start method from fork to
> +    # fork-server, which is not compatible with the nose2 setup
> +    if multiprocessing.get_start_method() != 'fork':
> +        multiprocessing.set_start_method("fork")
> +        # set_start_method throws a RuntimeError if called more than
> +        # once.
> +        # Debian python3-nose2 0.15.1-2 includes a patch adding
> +        # another set_start_method() call, so monkey patch it out to
> +        # get rid of this
> +        multiprocessing.set_start_method = lambda *args: None
> +
>      sys.exit(main())
> -- 
> 2.47.3
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-06 19:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-01 13:45 [Buildroot] [PATCH] support/testing/run-tests: unbreak on Debian testing/unstable Peter Korsgaard
2026-03-02 12:21 ` Peter Korsgaard
2026-03-06 19:53 ` Thomas Perale via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox