:param q: PriorityQueue instance holding GarbageCollector entries
        :param ignore_priority: If True - all GarbageCollector entries should be resubmitted
                If False - only those entries whose waiting time has expired will be resubmitted
433009
def _flush_queue(self, q, ignore_priority=False):
        
        assert isinstance(q, PriorityQueue)

        current_timestamp = compute_release_time(lag_in_minutes=0)
        for _ in range(len(q)):
            entry = q.pop()
            assert isinstance(entry, PriorityEntry)

            if ignore_priority or entry.release_time < current_timestamp:
                self._resubmit_uow(entry.entry)
            else:
                q.put(entry)
                break
1223988
def process_queues(self, forced=False):
        """"""

        with self.lock:
            if (not forced and not self.must_process) or not self.queues_enabled:
                return
            self.must_process = False
        ARBITRATOR.awaken()
540043
function priorityFill( callback ) {
	var queue, prioritizedQueue;

	queue = config.queue.slice( priorityFill.pos );
	prioritizedQueue = config.queue.slice( 0, -config.queue.length + priorityFill.pos );

	queue.unshift( callback );
	queue.unshift.apply( queue, prioritizedQueue );

	config.queue = queue;

	priorityFill.pos += 1;
}
1216553
def get_queue(cls, name, priority=0, **fields_if_new):
        
        queue_kwargs = {'name': name, 'priority': priority}
        retries = 0
        while retries < 10:
            retries += 1
            try:
                queue, created = cls.get_or_connect(**queue_kwargs)
            except IndexError:
                # Failure during the retrieval https://friendpaste.com/5U63a8aFuV44SEgQckgMP
                # => retry
                continue
            except ValueError:
                # more than one (race condition https://github.com/yohanboniface/redis-limpyd/issues/82 ?)
                try:
                    queue = cls.collection(**queue_kwargs).instances()[0]
                except IndexError:
                    # but no more now ?!
                    # => retry
                    continue
                else:
                    created = False

            # ok we have our queue, stop now
            break

        if created and fields_if_new:
            queue.set_fields(**fields_if_new)

        return queue
1173414
def enqueue_request(self, request):
        '''
        
        '''
        if not request.dont_filter and self.dupefilter.request_seen(request):
            self.logger.debug("Request not added back to redis")
            return
        req_dict = self.request_to_dict(request)

        if not self.is_blacklisted(req_dict['meta']['appid'],
                                   req_dict['meta']['crawlid']):
            # grab the tld of the request
            ex_res = self.extract(req_dict['url'])
            key = "{sid}:{dom}.{suf}:queue".format(
                sid=req_dict['meta']['spiderid'],
                dom=ex_res.domain,
                suf=ex_res.suffix)

            curr_time = time.time()

            domain = "{d}.{s}".format(d=ex_res.domain, s=ex_res.suffix)

            # allow only if we want all requests or we want
            # everything but blacklisted domains
            # insert if crawl never expires (0) or time < expires
            if (self.backlog_blacklist or
                    (not self.backlog_blacklist and
                    domain not in self.black_domains)) and \
                    (req_dict['meta']['expires'] == 0 or
                    curr_time < req_dict['meta']['expires']):
                # we may already have the queue in memory
                if key in self.queue_keys:
                    self.queue_dict[key][0].push(req_dict,
                                              req_dict['meta']['priority'])
                else:
                    # shoving into a new redis queue, negative b/c of sorted sets
                    # this will populate ourself and other schedulers when
                    # they call create_queues
                    self.redis_conn.zadd(key, ujson.dumps(req_dict),
                                        -req_dict['meta']['priority'])
                self.logger.debug("Crawlid: '{id}' Appid: '{appid}' added to queue"
                    .format(appid=req_dict['meta']['appid'],
                            id=req_dict['meta']['crawlid']))
            else:
                self.logger.debug("Crawlid: '{id}' Appid: '{appid}' expired"
                                  .format(appid=req_dict['meta']['appid'],
                                          id=req_dict['meta']['crawlid']))
        else:
            self.logger.debug("Crawlid: '{id}' Appid: '{appid}' blacklisted"
                              .format(appid=req_dict['meta']['appid'],
                                      id=req_dict['meta']['crawlid']))
378022
def _priority_range(policy=None):
    
    if policy is None:
        policy = libc.sched_getscheduler(0)
        if policy < 0:
            raise OSError(get_errno(),"sched_getscheduler")
    max = libc.sched_get_priority_max(policy)
    if max < 0:
        raise OSError(get_errno(),"sched_get_priority_max")
    min = libc.sched_get_priority_min(policy)
    if min < 0:
        raise OSError(get_errno(),"sched_get_priority_min")
    return (min,max)
516259
def priority(self, item):
        
        return '%.1f' % max(self.cache[item.pk][0] / self.max_entries, 0.1)
279270
def insert_tasks_ignore_duplicate_names(tasks, queue, *args, **kwargs):
    

    from google.appengine.api import taskqueue

    try:
        inserted = _insert_tasks(tasks, queue, *args, **kwargs)

        return inserted
    except taskqueue.DuplicateTaskNameError:
        # At least one task failed in our batch, attempt to re-insert the
        # remaining tasks.  Named tasks can never be transactional.
        reinsert = _tasks_to_reinsert(tasks, transactional=False)

        count = len(reinsert)
        inserted = len(tasks) - count

        # Our subsequent task inserts should raise TaskAlreadyExistsError at
        # least once, but that will be swallowed by _insert_tasks.
        for task in reinsert:
            inserted += _insert_tasks([task], queue, *args, **kwargs)

        return inserted
267724
private static void addOrder(Criteria c, String sort, String order, boolean ignoreCase) {
        if (ORDER_DESC.equals(order)) {
            c.addOrder(ignoreCase ? Order.desc(sort).ignoreCase() : Order.desc(sort));
        }
        else {
            c.addOrder(ignoreCase ? Order.asc(sort).ignoreCase() : Order.asc(sort));
        }
    }
222164
def _ensure_queue(self):
        """"""
        if self._queue_path not in self._client.kv:
            self._client.kv[self._queue_path] = None
931270
def set_priority(self, p_priority):
        
        if not self.is_completed() and (p_priority is None or
                                        is_valid_priority(p_priority)):
            self.fields['priority'] = p_priority

            priority_str = '' if p_priority is None else '(' + p_priority + ') '
            self.src = re.sub(r'^(\([A-Z]\) )?', priority_str, self.src)
1062745
def pq(ui, repo, *pats, **opts):
	
	opts['quick'] = True
	return pending(ui, repo, *pats, **opts)
660708
def wrapper__ignore(self, type_):
        
        if type_ not in self.__exclusion_list:
            self.__exclusion_list.append(type_)
        return self.__exclusion_list
957915
async def purgeQueues(self, *args, **kwargs):
        

        return await self._makeApiCall(self.funcinfo["purgeQueues"], *args, **kwargs)
955494
def sort_by_priority(iterable, reverse=False, default_priority=10):
    
    return sorted(iterable, reverse=reverse, key=lambda o: getattr(o, 'priority', default_priority))
77285
def enqueue_or_delay(self, queue_name=None, priority=None,
                         delayed_until=None, prepend=False, queue_model=None):
        
        queue_name = self._get_queue_name(queue_name)

        fields = {'queued': '1'}

        if priority is not None:
            fields['priority'] = priority
        else:
            priority = self.priority.hget()

        in_the_future = delayed_until and delayed_until > datetime.utcnow()

        if in_the_future:
            fields['delayed_until'] = str(delayed_until)
            fields['status'] = STATUSES.DELAYED
        else:
            self.delayed_until.delete()
            fields['status'] = STATUSES.WAITING

        self.hmset(**fields)

        if queue_model is None:
            queue_model = self.queue_model
        queue = queue_model.get_queue(queue_name, priority)

        if in_the_future:
            queue.delay_job(self, delayed_until)
        else:
            queue.enqueue_job(self, prepend)
1323501
public void processQueue(
      Predicate<RequestHandler> handlerConsumer,
      Prioritizer prioritizer) {

    Comparator<RequestHandler> comparator =
        prioritizer == null ?
        Ordering.allEqual()::compare :
        (a, b) -> prioritizer.compareTo(
            a.getRequest().getDesiredCapabilities(), b.getRequest().getDesiredCapabilities());

    lock.writeLock().lock();
    try {

      newSessionRequests.stream()
          .sorted(comparator)
          .filter(handlerConsumer)
          .forEach(requestHandler -> {
            if (!removeNewSessionRequest(requestHandler)) {
              log.severe("Bug removing request " + requestHandler);
            }
          });
    } finally {
      lock.writeLock().unlock();
    }
  }