|
38 | 38 | _mp_fork_set = False |
39 | 39 | if not _mp_fork_set: |
40 | 40 | try: |
41 | | - # Default start method: "spawn" on every platform. |
42 | | - # |
43 | | - # fork() is fundamentally unsafe in a process that holds native |
44 | | - # framework state or non-main threads: |
45 | | - # - macOS: Apple frameworks (CFNetwork, Security, libdispatch) may |
46 | | - # SIGSEGV in forked children, producing silently-restarting worker |
47 | | - # processes with exitcode=-11. CPython switched its own macOS |
48 | | - # default to spawn in 3.8 for the same reason (bpo-33725). |
49 | | - # - all POSIX: forking while another thread holds a lock (e.g. the |
50 | | - # prometheus_client module-level lock, or the TaskHandler monitor |
51 | | - # thread restarting a worker) leaves that lock permanently held in |
52 | | - # the child -> silent deadlock. |
53 | | - # Workers (including the @worker_task decorator path) are pickle-safe, |
54 | | - # so spawn works everywhere. Deployments that rely on fork's |
55 | | - # copy-on-write inheritance can opt back in with |
56 | | - # CONDUCTOR_MP_START_METHOD=fork (re-exposing the hazards above). |
57 | | - # NOTE: spawn requires the standard `if __name__ == "__main__":` guard |
58 | | - # in the entrypoint script. |
59 | | - _default_method = "spawn" |
60 | | - _method = os.environ.get("CONDUCTOR_MP_START_METHOD", "").strip().lower() or _default_method |
61 | | - if _method not in _VALID_MP_START_METHODS: |
62 | | - logger.warning( |
63 | | - "Ignoring invalid CONDUCTOR_MP_START_METHOD=%r; falling back to %r", |
64 | | - _method, _default_method, |
65 | | - ) |
66 | | - _method = _default_method |
67 | | - set_start_method(_method) |
| 41 | + set_start_method("spawn") |
68 | 42 | _mp_fork_set = True |
69 | 43 | except Exception as e: |
70 | 44 | logger.info("error when setting multiprocessing.set_start_method - maybe the context is set %s", e.args) |
@@ -498,10 +472,7 @@ def __check_and_restart_processes(self) -> None: |
498 | 472 | logger.warning( |
499 | 473 | "Worker process %s was killed by signal %s. If this " |
500 | 474 | "repeats on every restart, the process is likely " |
501 | | - "crashing at startup: use the 'spawn' start method " |
502 | | - "(CONDUCTOR_MP_START_METHOD=spawn, the default) and " |
503 | | - "set PYTHONFAULTHANDLER=1 to capture the crashing " |
504 | | - "stack trace.", |
| 475 | + "crashing at startup. set PYTHONFAULTHANDLER=1 to capture the crashing stack trace.", |
505 | 476 | worker_name, -exitcode, |
506 | 477 | ) |
507 | 478 | if not self.restart_on_failure: |
|
0 commit comments