Return the next requests that should be dispatched.
510629
def next_batch(self, n=1):
        """"""
        if len(self.queue) == 0:
            return []
        batch = list(reversed((self.queue[-n:])))
        self.queue = self.queue[:-n]
        return batch
723191
def get_sorting(self, request, **resources):
        
        sorting = []

        if not request.GET:
            return sorting

        prefix = self._meta.dyn_prefix + 'sort'
        return request.GET.getlist(prefix)
33749
def next(self):
        """"""
        if self.iter == None:
            self.iter = iter(self.objs)
        try:
            return self.iter.next()
        except StopIteration:
            self.iter = None
            self.objs = []
            if int(self.page) < int(self.total_pages):
                self.page += 1
                self._connection.get_response(self.action, self.params, self.page, self)
                return self.next()
            else:
                raise
787108
def await_reservations(self):
    """"""
    done = False
    while not done:
      done = self._request('QUERY')
      time.sleep(1)
    return self.get_reservations()
1010436
def _finish_pending_requests(self) -> None:
        
        while True:
            num_q, ok_list, err_list = self._multi.info_read()
            for curl in ok_list:
                self._finish(curl)
            for curl, errnum, errmsg in err_list:
                self._finish(curl, errnum, errmsg)
            if num_q == 0:
                break
        self._process_queue()
127416
def handle_json_GET_routes(self, params):
    """"""
    schedule = self.server.schedule
    result = []
    for r in schedule.GetRouteList():
      result.append( (r.route_id, r.route_short_name, r.route_long_name) )
    result.sort(key = lambda x: x[1:3])
    return result
920384
def next(self):
        """"""
        try:
            self._current = self.services.pop(0)
        except IndexError:
            raise StopIteration
        else:
            return self._current
72099
def first(self):
        """"""
        if self._results_cache:
            return self._results_cache[0]

        query = PaginatedResponse(func=self._func, lwrap_type=self._lwrap_type, **self._kwargs)
        try:
            return next(query)
        except StopIteration:
            return None
448888
def dispatch_queue(self):
        
        self.queue_lock.acquire()
        q = list(self.queue)
        self.queue = []
        self.queue_lock.release()
        log.debug("Dispatching requests: {}".format(q))
        for req in q:
            req.response = self.dispatch_request(req)
        for req in q:
            req.signal()
1051072
def _request_bulk(self, urls: List[str]) -> List:
        """"""
        if not urls:
            raise Exception("No results were found")
        session: FuturesSession = FuturesSession(max_workers=len(urls))
        self.log.info("Bulk requesting: %d" % len(urls))
        futures = [session.get(u, headers=gen_headers(), timeout=3) for u in urls]
        done, incomplete = wait(futures)
        results: List = list()
        for response in done:
            try:
                results.append(response.result())
            except Exception as err:
                self.log.warn("Failed result: %s" % err)
        return results
1059514
def _get_next_page_response(self):
        
        params = self._get_query_params()
        if self._page_size is not None:
            params["maxResults"] = self._page_size
        return self.api_request(
            method=self._HTTP_METHOD, path=self.path, query_params=params
        )
4464
def next(self):
        

        try:
            self._fetch()
            pkt = self.pkt_queue.popleft()
            try:
                self._infer_acked(pkt)
            except:
                pass
            try:
                self._infer_retry(pkt)
            except:
                pass

            return pkt
        except IndexError:
            raise StopIteration()
92820
def __spawn_new_requests(self):
        

        self.__should_spawn_new_requests = False

        in_progress_count = len(self.queue.get_all(QueueItem.STATUS_IN_PROGRESS))

        while in_progress_count < self.__options.performance.max_threads:
            if self.__spawn_new_request():
                in_progress_count += 1
            else:
                break

        if in_progress_count == 0:
            self.__crawler_stop()
915571
def request_done(self, request):
        """"""
        if self._requests is None:
            # Channel been cleaned up because the connection was lost.
            return

        assert request == self._requests[0], "Unexpected request done"
        del self._requests[0]

        if request.persistent:
            # Activate the next request in the pipeline if any
            if self._requests:
                self._requests[0].activate()
        else:
            self.transport.loseConnection()
382648
def next_page(self):
        
        for link in self.links:
            if link.next:
                return self._load(link.next)
        raise PaginationError('No more entries.')
727189
def next_batch(self):
        
        is_success, results = AtlasRequest(
            url_path=self.atlas_url,
            user_agent=self._user_agent,
            server=self.server,
            verify=self.verify,
        ).get()

        if not is_success:
            raise APIResponseError(results)

        self.total_count = results.get("count")
        self.atlas_url = self.build_next_url(results.get("next"))
        self.current_batch = results.get("results", [])
145305
def requests(self):
        ''''''
        path = pathjoin(self.path, self.name, Request.path)
        response = self.service.send(SRequest('GET', path))
        # a bin behaves as a push-down store --- better to return the requests
        # in order of appearance
        return list(reversed(Request.from_response(response, bin=self)))