How to use multiprocessing.Queue.get method?

前端 未结 3 872
情歌与酒
情歌与酒 2020-12-07 00:09

The code below places three numbers in a queue. Then it attempts to get the numbers back from the queue. But it never does. How to get the data from the queue?



        
3条回答
  •  渐次进展
    2020-12-07 00:30

    Check queue before using get:

    import multiprocessing
    
    queue = multiprocessing.Queue()
    
    for i in range(3):
        queue.put(i)
    
    while not queue.empty():
        if not queue.empty():
            print queue.get()
    

提交回复
热议问题