[Python] Starting multiprocessing.Process() in a Pytest test/Python creates a Windows fatal...

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    On windows, running the below code with Python or pytest makes it print out Windows fatal exception: access violation (but the script will continue with no issue)

    Reproduction:

    import multiprocessing as mp
    import faulthandler
    faulthandler.enable()

    def test_reproduce():
    p = mp.Process()
    p.start()
    p.join()

    if __name__ == "__main__":
    print("Direct run:")
    test_reproduce()
    print("Success")


    Trace:

    Windows fatal exception: access violation

    Current thread 0x00000f48 (most recent call first):
    File "C:\Python\cpython-3.10.16-windows-x86_64-none\lib\multiprocessing\popen_spawn_win32.py", line 73 in __init__
    File "C:\Python\cpython-3.10.16-windows-x86_64-none\lib\multiprocessing\context.py", line 336 in _Popen
    File "C:\Python\cpython-3.10.16-windows-x86_64-none\lib\multiprocessing\context.py", line 224 in _Popen
    File "C:\Python\cpython-3.10.16-windows-x86_64-none\lib\multiprocessing\process.py", line 121 in start
    File "C:\src\sandbox\minimal.py", line 5 in test_reproduce


    This points to the _winapi.CreateProcess() function.

    Note that if faulthandler is not enabled, this will not be shown to the user when running with Python, whereas Pytest enables the faulthandler for you.

    Happens on two of my computers, Windows 11 and Windows 10. Python 3.10 and Python 3.12. This has definitely also worked before so I am not sure what has changed.

    Continue reading...

Compartilhe esta Página