FelipeG FelipeG - 1 year ago 743
Python Question

How to clear a multiprocessing queue in 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

Answer Source

There is no direct way of clearing a multiprocessing.Queue.

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download