Why Does a Python Multiprocessing Script Work on Linux but Fail on Windows?

Asked 17 hours ago 54 views

0

I have a small Python script that starts a worker process. It runs as expected on Linux, but on Windows it appears to start the script again inside the child process and then fails with a bootstrapping error.

Here’s the simplified pattern I’m using:

from multiprocessing import Process


def work():
    print("Worker started")


# Starting a process at module level may run again when Windows imports this file.
worker = Process(target=work)
worker.start()

Is the difference mainly down to how Windows starts child processes, or could something else cause this behavior? I’d like to understand the Windows multiprocessing startup rules before adapting a larger script.

0 Answers


Write Your Answer