This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Queue import Queue | |
from threading import RLock | |
class SetQueue(Queue): | |
""" | |
Queue class is thread-safe, so it can be used in scenarios where multiple threads will try accessing the queue. | |
But default implementation has a downside, it is not iterable and you can't check if it contains an item or not, | |
so you can't see if you are adding a duplicate item or not. | |
To overcome this problem, a SetQueue implementation is propsed. | |
This implementation is grabbed from here: http://stackoverflow.com/questions/1581895/how-check-if-a-task-is-already-in-python-queue |
NewerOlder