If all processes try to close the Queue immediately after someone has written to it, this causes an error (see the link for more details). Uncommenting any of the time.sleeps makes it work consistently again.
importmultiprocessingimporttimeimportloggingimportmultiprocessing.utilmultiprocessing.util.log_to_stderr(level=logging.DEBUG)
queue=multiprocessing.Queue(maxsize=10)
defworker(queue):
queue.put('abcdefghijklmnop')
# "Indicate that no more data will be put on this queue by the# current process." --Documentation# time.sleep(0.01)queue.close()
proc=multiprocessing.Process(target=worker, args=(queue,))
proc.start()
# "Indicate that no more data will be put on this queue by the current# process." --Documentation# time.sleep(0.01)queue.close()
proc.join()
Perhaps this is because I am not understanding the documentation correctly, but in that case I would contend this is a documentation bug.
Traceback (most recent call last):
File "/usr/lib/python3.7/multiprocessing/queues.py", line 242, in _feed
send_bytes(obj)
File "/usr/lib/python3.7/multiprocessing/connection.py", line 200, in send_bytes
self._send_bytes(m[offset:offset + size])
File "/usr/lib/python3.7/multiprocessing/connection.py", line 404, in _send_bytes
self._send(header + buf)
File "/usr/lib/python3.7/multiprocessing/connection.py", line 368, in _send
n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe
Activity
charmonium commented on Jan 28, 2019
If all processes try to close the Queue immediately after someone has written to it, this causes an error (see the link for more details). Uncommenting any of the time.sleeps makes it work consistently again.
Perhaps this is because I am not understanding the documentation correctly, but in that case I would contend this is a documentation bug.
Traceback (most recent call last): File "/usr/lib/python3.7/multiprocessing/queues.py", line 242, in _feed send_bytes(obj) File "/usr/lib/python3.7/multiprocessing/connection.py", line 200, in send_bytes self._send_bytes(m[offset:offset + size]) File "/usr/lib/python3.7/multiprocessing/connection.py", line 404, in _send_bytes self._send(header + buf) File "/usr/lib/python3.7/multiprocessing/connection.py", line 368, in _send n = write(self._handle, buf) BrokenPipeError: [Errno 32] Broken pipegeryogam commented on May 11, 2022
@JelleZijlstra, could you also close this issue now that it has been fixed in PR #31913?