Cannot realize why this simple code putting 1,2,3 into queue give me as many such errors (repeat it here as well 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
as values I trying to put. But just in case if I am trying to job_queue.close()
(but after the queue seems to be empty).
And why these errors seems not to be catched with my except
's? :/
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")