如何在python中清除多处理队列 [英] How to clear a multiprocessing queue in python

查看:1522
本文介绍了如何在python中清除多处理队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想知道如何像普通python队列一样清除python中的多处理队列.例如:

I just want to know how to clear a multiprocessing queue in python like a normal python queue. For instance:

from multiprocessing import Queue  # multiprocessing queue
from Queue import Queue            # normal queue

multi_q = Queue()
normal_q = Queue()
multi_q.clear()                    # or multi_q.queue.clear() 

队列"对象没有属性清除"

'Queue' object has no attribute 'clear'

normal_q.queue.clear() # This is ok

推荐答案

没有清除multiprocessing.Queue的直接方法.

我相信离您最近的是close(),但这只是声明不再将更多数据推送到该队列,并且在所有数据都已刷新到管道后将关闭它.

I believe the closest you have is close(), but that simply states that no more data will be pushed to that queue, and will close it when all data has been flushed to the pipe.

这篇关于如何在python中清除多处理队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆