Multiprocessing (windows 10) BrokenPipeError: [Errno 32] Broken pipe

The key part that should be inside the if __name__ == "__main__": is pm.sample, because the process pool is created there. Try it, and if that works, great, but you could still get a broken pipe exception.

As @aseyboldt said, the main problem seems to be that if for whatever reason a child process fails and raises an exception, the parent process does not seem to know about it. This means that the parent goes on with its tasks, keeps trying to communicate with the child, then finds out that the communication pipe is broken and raises the BrokenPipeError exception, which is not helpful at all to find out what caused the child to break.

What allowed me to see the exception that was raised by the child was to run the script in a system dedicated terminal. The child process was able to write to stderr of this terminal and its exception became visible, enabling me to try to solve the problem.

My recommendation then is to try to reorganize your code to put the pm.sample inside if __name__ == __main__: but to also run your code in a system dedicated terminal. At least that way, if your code keeps failing, you could see the failed child’s traceback.