def get(self, *args, **kwargs): task = queue.PriorityQueue.get(self, *args, **kwargs) logger.debug("Q. Get:" + str(task)) if ISingletonTask.providedBy(task): self.singleton_lock.acquire() try: del self.singletons[task.__class__] except KeyError: pass self.singleton_lock.release() return task
def put(self, task, context=None, view=None, *args, **kwargs): logger.debug("Q. Put: " + str(task)) if ISingletonTask.providedBy(task): self.singleton_lock.acquire() task_existed = task.__class__ in self.singletons if not task_existed: self.singletons[task.__class__] = task self.singleton_lock.release() if task_existed: return True ctx = None if view != None: ctx = {"request": view.request, "registry": view.request.registry} if context != None: ctx = context task.set_context(ctx) return queue.PriorityQueue.put(self, task, *args, **kwargs)