Get all items from thread Queue

后端 未结 6 1754
别那么骄傲
别那么骄傲 2021-02-13 05:14

I have one thread that writes results into a Queue.

In another thread (GUI), I periodically (in the IDLE event) check if there are results in the queue, like this:

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-13 05:44

    I think the easiest way of getting all items out of the queue is the following:

    def get_all_queue_result(queue):
    
        result_list = []
        while not queue.empty():
            result_list.append(queue.get())
    
        return result_list
    

提交回复
热议问题