I stuck with understanding quite simple case. Please, can someone explain or show the direction to understand the following:
import multiprocessing as mp
if __name__ == '__main__':
input_queue = mp.Queue()
for i in range(5):
input_queue.put([i]*5)
print(input_queue.qsize())
while not input_queue.empty():
o = input_queue.get()
print(o)
Output:
5
[0, 0, 0, 0, 0]
[1, 1, 1, 1, 1]
[2, 2, 2, 2, 2]
[3, 3, 3, 3, 3]
[4, 4, 4, 4, 4]
But:
import multiprocessing as mp
if __name__ == '__main__':
input_queue = mp.Queue()
for i in range(5):
input_queue.put([i]*5)
# print(input_queue.qsize())
while not input_queue.empty():
o = input_queue.get()
print(o)
Output nothing
Update:
import multiprocessing as mp
if __name__ == '__main__':
input_queue = mp.Queue()
for i in range(5):
input_queue.put([i]*5)
for _ in range(5):
o = input_queue.get()
print(o)
Print expected output. So probably issue in .empty() method.
python --version
Python 3.6.9 :: Anaconda, Inc.