Answer a question

I just want to know how to clear a multiprocessing.Queue like a queue.Queue in Python:

>>> import queue
>>> queue.Queue().clear()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Queue' object has no attribute 'clear'
>>> queue.Queue().queue.clear()
>>> import multiprocessing
>>> multiprocessing.Queue().clear()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Queue' object has no attribute 'clear'
>>> multiprocessing.Queue().queue.clear()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Queue' object has no attribute 'queue'

Answers

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.

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐