Collect all immediately available items from a queue
184065
def get_nowait_from_queue(queue):
    
    data = []
    for _ in range(queue.qsize()):
        try:
            data.append(queue.get_nowait())
        except q.Empty:
            break
    return data
26105
def reserve(cls, queues, res, worker=None, timeout=10):
        
        if isinstance(queues, string_types):
            queues = [queues]
        queue, payload = res.pop(queues, timeout=timeout)
        if payload:
            return cls(queue, payload, res, worker)
158785
def queue_raw_jobs(queue, params_list, **kwargs):
    

    from .queue import Queue
    queue_obj = Queue(queue)
    queue_obj.enqueue_raw_jobs(params_list, **kwargs)
699090
def _save_queue(self):
        """"""
        if self.queue is not None:
            # Maximum batch is 486, anything larger will still only
            # return 486
            batch_size = 400
            total = 0
            num_return = batch_size

            # Need to get all the tracks in batches, but Only get the next
            # batch if all the items requested were in the last batch
            while num_return == batch_size:
                queue_items = self.device.get_queue(total, batch_size)
                # Check how many entries were returned
                num_return = len(queue_items)
                # Make sure the queue is not empty
                if num_return > 0:
                    self.queue.append(queue_items)
                # Update the total that have been processed
                total = total + num_return
592254
def flush_queue(self):
        """"""
        records = []

        while not self.queue.empty() and len(records) < self.batch_size:
            records.append(self.queue.get())

        if records:
            self.send_records(records)
            self.last_flush = time.time()
721895
def gather(self):
        
        limit = self.op_sequence - self.op_sequence_start
        results = MessageIterator(self.sqs, self.reduce_queue, limit)
        for m in results:
            # sequence_id from above
            msg_id = int(m['MessageAttributes']['sequence_id']['StringValue'])
            if (not msg_id > self.op_sequence_start or not msg_id <= self.op_sequence or
            msg_id not in self.futures):
                raise RuntimeError(
                    "Concurrent queue user from different "
                    "process or previous results")
            f = self.futures[msg_id]
            f.set_result(m)
            results.ack(m)
1193264
def fetch(*queues)
      job = nil
      transaction do
        command("FETCH", *queues)
        job = result!
      end
      JSON.parse(job) if job
    end
1194087
def process_queue(self):
        
        m = pycurl.CurlMulti()
        m.handles = []

        # Loop the queue and create Curl objects for processing
        for item in self._queue:
            c = self._create_curl(*item)
            m.add_handle(c)
            m.handles.append(c)

        # Process the collected Curl handles
        num_handles = len(m.handles)
        while num_handles:
            while 1:
                # Perform the calls
                ret, num_handles = m.perform()
                if ret != pycurl.E_CALL_MULTI_PERFORM:
                    break
            m.select(1.0)

        # Collect data
        results = []
        for c in m.handles:
            c.status = c.getinfo(c.HTTP_CODE)
            if 'Content-Encoding: gzip' in c.response_headers.getvalue():
                c.body = cStringIO.StringIO(self._gunzip_body(c.body.getvalue()))
            result = { "data" : self._digest_result(c.body.getvalue()), "code": c.status }
            if not c.status or c.status >= 400:
                # Don't throw the exception because some might have succeeded
                result['exception'] = HapiThreadedError(c)

            results.append(result)

            
        # cleanup
        for c in m.handles:
            if hasattr(c, "data_out"):
                c.data_out.close()

            c.body.close()
            c.response_headers.close()
            c.close()
            m.remove_handle(c)

        m.close()
        del m.handles
        self._queue = []

        return results
890186
async def poll(self):
        """"""
        try:
            packets = [await asyncio.wait_for(self.queue.get(),
                                              self.server.ping_timeout)]
            self.queue.task_done()
        except (asyncio.TimeoutError, asyncio.CancelledError):
            raise exceptions.QueueEmpty()
        if packets == [None]:
            return []
        try:
            packets.append(self.queue.get_nowait())
            self.queue.task_done()
        except asyncio.QueueEmpty:
            pass
        return packets
107095
async function fetchAll(connection, query, params){

    // execute query
    const [result] = await _query(connection, query, params);

    // entry found ?
    return result || [];
}
305135
def popitem(self):
        """"""
        pq = self.pq
        while pq:
            priority, key, val = heapq.heappop(pq)
            if val is None:
                self.removed_count -= 1

            else:
                del self.item_finder[key]
                return key, val, priority

        raise KeyError("pop from an empty priority queue")
841210
def sreenqueue(item_id, item_s, *args, **kwargs):
    '''
    '''
    return vsreenqueue(item_id, item_s, args, **kwargs)
161832
def _fetch_all(self):
        
        if self._result_cache is None:
            self._result_cache = list(self.iterator())
            # TODO: Do we have to test for ValuesListIterable, ValuesIterable,
            # and FlatValuesListIterable here?
            if self._iterable_class == ModelIterable:
                for x in self._result_cache:
                    self._set_item_querytime(x)
        if self._prefetch_related_lookups and not self._prefetch_done:
            self._prefetch_related_objects()
194072
def all(cls, path=''):
        """"""
        url = urljoin(cls._meta.base_url, path)
        pq_items = cls._get_items(url=url, **cls._meta._pyquery_kwargs)
        return [cls(item=i) for i in pq_items.items()]
273665
function(options) {
            this.queue.defer(function() {
                options = _.defaults(options || {}, {
                    refresh: false
                });
                var d, self = this;

                if (this.options.loader == null) return this;
                if (options.refresh) {
                    this.options.startIndex = 0;
                    this._totalCount = null;
                    this.reset([]);
                }

                if (this._totalCount == null || this.hasMore() > 0 || options.refresh) {
                    this.options.startIndex = this.options.startIndex || 0;
                    d = Q(this[this.options.loader].apply(this, this.options.loaderArgs || []));
                    d.done(function() {
                        self.options.startIndex = self.options.startIndex + self.options.limit
                    });
                } else {
                    d = Q.reject();
                }

                return d;
            }, this);

            return this;
        }
616584
def all(cls):
        

        # Start with raw queues we know exist from the config
        queues = {x: 0 for x in Queue.get_queues_config()}

        stats = list(context.connections.mongodb_jobs.mrq_jobs.aggregate([
            {"$match": {"status": "queued"}},
            {"$group": {"_id": "$queue", "jobs": {"$sum": 1}}}
        ]))

        queues.update({x["_id"]: x["jobs"] for x in stats})

        return queues
923033
def put(self, item, block=True, timeout=None):
        """"""
        return self._queue.put(item, block, timeout)