Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import multiprocessing
- class ItemExists(Exception):
- pass
- class SetQueue(multiprocessing.JoinableQueue):
- def __init__(self, maxsize=0):
- super(SetQueue,self).__init__(maxsize)
- self.all_items = set()
- def put(self, obj, block=True,timeout=None):
- if obj not in self.all_items:
- super(SetQueue,self).put(obj,block,timeout)
- self.all_items.add(item)
- else:
- raise ItemExists
- def get(self, block = True, timeout = None):
- res = super(SetQueue,self).get( block, timeout)
- self.all_items.discard(res)
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement