ibcplateformes Claude Opus 4.6 commited on
Commit
db251d2
·
1 Parent(s): a89afd6

Fix 'context has already been set' multiprocessing error

Browse files

Neutralize mp.set_start_method() calls from Applio/torch by using
force=True and catching RuntimeError.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. pipeline/training.py +13 -0
pipeline/training.py CHANGED
@@ -31,6 +31,19 @@ from pipeline.setup import APPLIO_DIR
31
 
32
  LOGS_DIR = os.path.join(APPLIO_DIR, "logs")
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  def _setup_applio_env():
36
  """Ensure Applio is on sys.path."""
 
31
 
32
  LOGS_DIR = os.path.join(APPLIO_DIR, "logs")
33
 
34
+ # Prevent "context has already been set" errors from Applio/torch
35
+ # by neutralizing mp.set_start_method calls
36
+ import multiprocessing as _mp
37
+ _orig_set_start_method = _mp.set_start_method
38
+
39
+ def _safe_set_start_method(method=None, force=False):
40
+ try:
41
+ _orig_set_start_method(method, force=True)
42
+ except RuntimeError:
43
+ pass
44
+
45
+ _mp.set_start_method = _safe_set_start_method
46
+
47
 
48
  def _setup_applio_env():
49
  """Ensure Applio is on sys.path."""