GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — multiprocessing's default posix start method of `'fork'` is broken: change to ``'forkserver' || 'spawn'` · Issue #84559 · python/cpython

multiprocessing's default posix start method of 'fork' is broken: change to `'forkserver' || 'spawn' #84559

New issue
Copy link
New issue
Copy link
Closed
Closed
multiprocessing's default posix start method of 'fork' is broken: change to `'forkserver' || 'spawn'#84559
Copy link
Assignees
gpshead
Labels
3.14bugs and security fixesbugs and security fixestopic-multiprocessingtype-featureA feature request or enhancementA feature request or enhancement

Description

itamarst
mannequin
opened on Apr 24, 2020
Issue body actions
BPO 40379
Nosy @pitrou, @mgorny, @Julian, @wimglenn, @applio, @itamarst

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-04-24.18:22:23.389>
labels = ['3.8', 'type-bug', '3.7', '3.9']
title = "multiprocessing's default start method of fork()-without-exec() is broken"
updated_at = <Date 2022-02-11.16:13:53.872>
user = 'https://bugs.python.org/itamarst'

bugs.python.org fields:

activity = <Date 2022-02-11.16:13:53.872>
actor = 'mgorny'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2020-04-24.18:22:23.389>
creator = 'itamarst'
dependencies = []
files = []
hgrepos = []
issue_num = 40379
keywords = []
message_count = 11.0
messages = ['367210', '367211', '368173', '380478', '392358', '392501', '392503', '392506', '392507', '392508', '413081']
nosy_count = 8.0
nosy_names = ['pitrou', 'mgorny', 'Julian', 'wim.glenn', 'itamarst', 'davin', 'itamarst2', 'aduncan']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue40379'
versions = ['Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9']

Linked PRs

  • GH-84559: Deprecate fork being the multiprocessing default. #100618
  • gh-84559: skip the test when no multiprocessing (wasm, etc) #101530
  • gh-84559: Remove the new multiprocessing warning, too disruptive. #101551
  • gh-84559: Change the multiprocessing start method default to forkserver #101556
  • gh-84559: gh-103134: Whats new 3.14 entries for multiprocessing. #126697
  • gh-84559: multiprocessing: detect if forkserver cannot work due to missing hmac-sha256 #127467
  • gh-84559: improve What's New entry for multiprocessing start method changes #128173
  • [3.13] gh-84559: improve What's New entry for multiprocessing startmethod changes (GH-128173) #137156
Reacted by Hash, Hafidh Rendyanto, Gregory P. Smith, Giangpro89, heimalne, Jonah George, Will Thompson, Philipp Moritz, Aidan and Ningú

Activity

Next
  1. itamarst commented on Apr 24, 2020

    @itamarst
    itamarstmannequin
    on Apr 24, 2020
    MannequinAuthor
    More actions

    By default, multiprocessing uses fork() without exec() on POSIX. For a variety of reasons this can lead to inconsistent state in subprocesses: module-level globals are copied, which can mess up logging, threads don't survive fork(), etc..

    The end results vary, but quite often are silent lockups.

    In real world usage, this results in users getting mysterious hangs they do not have the knowledge to debug.

    The fix for these people is to use "spawn" by default, which is the default on Windows.

    Just a small sample:

    1. Today I talked to a scientist who spent two weeks stuck, until she found my article on the subject (https://codewithoutrules.com/2018/09/04/python-multiprocessing/). Basically multiprocessing locked up, doing nothing forever. Switching to "spawn" fixed it.
    2. Default multiprocessing context is broken and should never be used dask/dask#3759 (comment) is someone who had issues fixed by "spawn".
    3. matmul operator @ can freeze / hang when used with default python multiprocessing using fork context instead of spawn numpy/numpy#15973 is a NumPy issue which apparently impacted scikit-learn.

    I suggest changing the default on POSIX to match Windows.

  2. itamarst
    added
    3.7 (EOL)end of lifeend of life
    3.8 (EOL)end of lifeend of life
    3.9 (EOL)end of lifeend of life
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 24, 2020
  3. itamarst commented on Apr 24, 2020

    @itamarst
    itamarstmannequin
    on Apr 24, 2020
    MannequinAuthor
    More actions

    Looks like as of 3.8 this only impacts Linux/non-macOS-POSIX, so I'll amend the above to say this will also make it consistent with macOS.

    Reacted by jakirkham, Diony Rosa and Ningú
  4. itamarst commented on May 5, 2020

    @itamarst
    itamarstmannequin
    on May 5, 2020
    MannequinAuthor
    More actions

    Just got an email from someone for whom switching to "spawn" fixed a problem. Earlier this week someone tweeted about this fixing things. This keeps hitting people in the real world.

  5. itamarst commented on Nov 6, 2020

    @itamarst
    itamarstmannequin
    on Nov 6, 2020
    MannequinAuthor
    More actions

    Another person with the same issue: https://twitter.com/volcan01010/status/1324764531139248128

  6. aduncan commented on Apr 29, 2021

    @aduncan
    aduncanmannequin
    on Apr 29, 2021
    Mannequin
    More actions

    I just ran into and fixed (thanks to itamarst's blog post) a problem likely related to this.

    Multiprocessing workers performing work and sending a logging message back with success/fail info. I had a few intermittent deadlocks that became a recurring problem when I sped up the process that skipped tasks which had previously completed (I think this shortened the time between forking and attempting to send messages causing the third process to deadlock). After changing that it deadlocked *every time*.

    Switching to "spawn" at the top of the main function has fixed it.

  7. pitrou commented on Apr 30, 2021

    @pitrou
    pitrou
    on Apr 30, 2021
    Member
    More actions

    The problem with changing the default is that this will break any application that depends on passing non-picklable data to the child process (in addition to the potentially unexpected performance impact).

    The docs already contain a significant elaboration on the matter, but feel free to submit a PR that would make the various caveats more explicit:
    https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

    Reacted by Oskar Skog
  8. itamarst commented on Apr 30, 2021

    @itamarst
    itamarstmannequin
    on Apr 30, 2021
    MannequinAuthor
    More actions

    This change was made on macOS at some point, so why not Linux? "spawn" is already the default on macOS and Windows.

  9. pitrou commented on Apr 30, 2021

    @pitrou
    pitrou
    on Apr 30, 2021
    Member
    More actions

    The macOS change was required before "fork" simply ceased to work.
    Windows has always used "spawn", because no other method can be implemented on Windows.

  10. itamarst commented on Apr 30, 2021

    @itamarst
    itamarstmannequin
    on Apr 30, 2021
    MannequinAuthor
    More actions

    Given people's general experience, I would not say that "fork" works on Linux either. More like "99% of the time it works, 1% it randomly breaks in mysterious way".

  11. pitrou commented on Apr 30, 2021

    @pitrou
    pitrou
    on Apr 30, 2021
    Member
    More actions

    Agreed, but again, changing will break some applications.

    We could switch to forkserver, but we should have a transition period where a FutureWarning will be displayed if people didn't explicitly set a start method.

  12. mgorny commented on Feb 11, 2022

    @mgorny
    mgornymannequin
    on Feb 11, 2022
    Mannequin
    More actions

    After updating PyPy3 to use Python 3.9's stdlib, we hit very bad hangs because of this — literally compiling a single file with "parallel" compileall could hang. In the end, we had to revert the change in how Python 3.9 starts workers because otherwise multiprocessing would be impossible to use:

    https://foss.heptapod.net/pypy/pypy/-/commit/c594b6c48a48386e8ac1f3f52d4b82f9c3e34784

    This is a very bad default and what's even worse is that it often causes deadlocks that are hard to reproduce or debug. Furthermore, since "fork" is the default, people are unintentionally relying on its support for passing non-pickleable projects and are creating non-portable code. The code often becomes complex and hard to change before they discover the problem.

    Before we managed to figure out how to workaround the deadlocks in PyPy3, we were experimenting with switching the default to "spawn". Unfortunately, we've hit multiple projects that didn't work with this method, precisely because of pickling problems. Furthermore, they were surprised to learn that their code wouldn't work on macOS (in the end, many people perceive Python as a language for writing portable software).

    Finally, back in 2018 I've made one of my projects do parallel work using multiprocessing. It gave its users great speedup but for some it caused deadlocks that I couldn't reproduce nor debug. In the end, I had to revert it. Now that I've learned about this problem, I'm wondering if this wasn't precisely because of "fork" method.

    Reacted by Andre Merzky
  13. 86 remaining items

  14. suo
    added 2 commits that reference this issue on Jul 18, 2025

    Update base for Update on "[monarch] use spawn as multiprocessing sta…

    0336276

    Update on "[monarch] use spawn as multiprocessing start method"

    1867583
  15. facebook-github-bot
    added a commit that references this issue on Jul 18, 2025

    use spawn as multiprocessing start method (#564)

    cef93c7
  16. brianschubert
    added a commit that references this issue on Jul 27, 2025

    [3.13] pythongh-84559: improve What's New entry for `multiprocessing`…

    ef1acf3
  17. gpshead
    added a commit that references this issue on Jul 28, 2025

    [3.13] gh-84559: improve What's New entry for `multiprocessing` start…

    c2b8a89
  18. marmarek
    added 3 commits that reference this issue on Sep 14, 2025

    Prepare salt.utils.process for python 3.14

    37a615c

    Prepare salt.utils.process for python 3.14

    ae4d59a

    Prepare multiprocessing handling for Python 3.14

    1004195
  19. kernc
    added 5 commits that reference this issue on Dec 20, 2025

    PERF: Revert multiprocessing start method change introduced in Python…

    487ef9c

    PERF: Revert multiprocessing start method change introduced in Python…

    2bd8177

    PERF: Revert multiprocessing start method change introduced in Python…

    0e674ae

    PERF: Revert multiprocessing start method change introduced in Python…

    cf9656c

    PERF: Revert multiprocessing start method change introduced in Python…

    6ffa512
  20. tasleson commented on Feb 4, 2026

    @tasleson
    tasleson
    on Feb 4, 2026
    More actions

    @asottile

    I doubt it's more than a fraction of a percent of python users or pypi packages -- anything that people actually use has already been updated or is abandoned

    I ran into this yesterday when code that has been running reliably since 2015 broke after upgrading to Python 3.14.

    Calling the impact “a fraction of a percent” misses the point at Python’s scale. Even small percentages represent a large amount of deployed, working code, much of which is intentionally unchanged because it is correct.

    Equating infrequent updates with lack of use conflates maintenance with usage. The success of any programming language depends on expectations of long-term stability, and changes like this undermine that.

    This kind of breakage also discourages writing new Python code, knowing it will have to be revisited later for no good reason.

  21. python
    locked as resolved and limited conversation to collaborators on Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @gpshead
    gpshead

Labels

3.14bugs and security fixesbugs and security fixestopic-multiprocessingtype-featureA feature request or enhancementA feature request or enhancement

Projects

  • Multiprocessing issues
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.