![](/img/trans.png)
[英]Python Multiprocessing queue.get() timeout when queue is not empty
[英]queue.get() with a cumulative timeout for n elements
只需計算剩余時間即可。
TIMEOUT=5
t = time.monotonic()+TIMEOUT
items = []
for n in range(25):
try:
items.append(q.get(timeout=t-time.monotonic()))
except queue.Empty:
break
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.