How to fix BrokenPipeError: [Errno 32] (Python, Windows 10)

Hi, I recently attempted to run a black hole simulator ( coded a couple years ago, and ran into a few problems. The one I’m currently stuck on is one concerning a pipe error, and, being fairly new to Python, I can’t seem to fix it.

This is what the console returns:

    Traceback (most recent call last):
  File "", line 925, in <module>
  File "C:\Users\artur\AppData\Local\Programs\Python\Python36\lib\multiprocessing\", line 105, in start
    self._popen = self._Popen(self)
  File "C:\Users\artur\AppData\Local\Programs\Python\Python36\lib\multiprocessing\", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\artur\AppData\Local\Programs\Python\Python36\lib\multiprocessing\", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Users\artur\AppData\Local\Programs\Python\Python36\lib\multiprocessing\", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\artur\AppData\Local\Programs\Python\Python36\lib\multiprocessing\", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe

I’ve tracked down the bug to the following lines:

process_list = []
for i in range(NTHREADS):
	p = multiprocessing.Process(target=raytrace_schedule,args=(i,schedules[i],total_colour_buffer_preproc_shared,output.queue))

logger.debug("Starting threads...")
for proc in process_list:

The way I see it, the problem is caused by the multiprocessing library, which must be attempting to write on a closed pipe.

I think it’s the same issue and solution as here.
Hope this helps :vulcan_salute:

1 Like

Actually, all I needed was an if statement (if __name__ == '__main__':) right before executing the multiprocessing library, as shown here: I’ll leave this here in case someone needs it. Thanks, though.

worked for me! thanks!