Не могу понять, почему этот простой код, помещающий 1,2,3 в очередь, дает мне столько таких ошибок (повторите и здесь https://repl.it/@coalesce/Where-s-Waldo)
File "/usr/local/lib/python3.7/multiprocessing/connection.py", line 368, in _send
n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe
как значения, которые я пытаюсь поместить. Но простов случае, если я пытаюсь job_queue.close()
(но после того, как очередь кажется пустой).
И почему эти ошибки, похоже, не улавливаются моими except
?: /
import sys
from multiprocessing import Queue
def put_items_to_q(q, n):
try:
for i in range(n):
q.put(i)
except (BrokenPipeError, IOError) as e:
sys.stdout.write("ERRROR HERE {} ? \n".format(e))
pass
if __name__ == '__main__':
sys.stdout.writelines( 'Starting\n')
job_queue = Queue()
put_items_to_q(job_queue, 3)
while not job_queue.empty():
try:
job_queue.get(block=False)
except (BrokenPipeError, IOError) as e:
sys.stdout.write("OR ERRROR HERE? {} \n".format(e))
break
if job_queue.empty():
sys.stdout.write("Q is empty\n")
try:
job_queue.close()
job_queue.join_thread()
pass
except (BrokenPipeError, IOError) as e:
sys.stdout.write("OR ERRROR HERE? {} \n".format(e))
pass
sys.stdout.write("End")