Get all items from thread Queue

后端 未结 6 1658
别那么骄傲
别那么骄傲 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:35

    If you're done writing to the queue, qsize should do the trick without needing to check the queue for each iteration.

    responseList = []
    for items in range(0, q.qsize()):
        responseList.append(q.get_nowait())
    

提交回复
热议问题