def _put_and_notify(self): with self.not_empty: while self.delayed: when, item = heapq.heappop(self.delayed) if when <= time.time(): Queue._put(self, item) self.not_empty.notify() else: heapq.heappush(self.delayed, (when, item)) break
def _put(self, item): delay, item = item if delay: if self.task.running: heapq.heappush(self.delayed, (time.time() + delay, item)) else: message = 'TimeDelayQueue.put called with a delay parameter without background task having been started' log.warning(message) warn(message) else: Queue._put(self, item)
def _put(self, item): if item in self._seen: self._discards += 1 # Handle if self.silent: return else: raise Duplicate Queue._put(self, item) self._seen.add(item)
def _put(self, xxx_todo_changeme): # Only consider re-evaluation if we are still on the same eval # session. (eval_sess, is_reeval) = xxx_todo_changeme if is_reeval and self._curr_eval_sess is not eval_sess: return replace = True if hasattr(eval_sess, "ctlr") and eval_sess.ctlr and eval_sess.ctlr.keep_existing: # Allow multiple eval sessions; currently used for variable # highlighting (bug 80095), may pick up additional uses. Note that # these sessions can still get wiped out by a single replace=False # caller. replace = False if replace: # We only allow *one* eval session at a time. # - Drop a possible accumulated eval session. if len(self.queue): pending = list(self.queue) self.queue.clear() for evalr, _ in pending: try: evalr.close() except: log.exception("Failed to close evalr") ## - Abort the current eval session. if not is_reeval and self._curr_eval_sess is not None: self._curr_eval_sess.ctlr.abort() # Lazily start the eval thread. if not self.isAlive(): self.start() Queue._put(self, (eval_sess, is_reeval)) if replace: assert len(self.queue) == 1