def _check_response(self, response): query = self.request term = query.term opts = query.global_optargs self._check_error_response(response, term) if response.type in SequenceResponse: # Sequence responses value = Cursor(self, query, opts) value._extend(response) elif response.type == pResponse.SUCCESS_ATOM: # Atom response if len(response.data) < 1: value = None value = recursively_convert_pseudotypes(response.data[0], opts) elif response.type == pResponse.WAIT_COMPLETE: # Noreply_wait response return None else: # Default for unknown response types raise RqlDriverError("Unknown Response type %d encountered in " "response." % response.type) if response.profile is not None: value = {"value": value, "profile": response.profile} return value
def _extend(self, res_buf): Cursor._extend(self, res_buf) if self.error is not None: self.items.cancel_getters(self.error) for d in self.waiting[:]: d.callback(None) self.waiting.remove(d)
def fetch_next(self, wait=True): timeout = Cursor._wait_to_timeout(wait) deadline = None if timeout is None else self.conn._io_loop.time() + timeout while len(self.items) == 0 and self.error is None: self._maybe_fetch_batch() yield with_absolute_timeout(deadline, self.new_response) # If there is a (non-empty) error to be received, we return True, so the # user will receive it on the next `next` call. raise gen.Return(len(self.items) != 0 or not isinstance(self.error, ReqlCursorEmpty))
async def fetch_next(self, wait=True): timeout = Cursor._wait_to_timeout(wait) while len(self.items) == 0: self._maybe_fetch_batch() if self.error is not None: raise self.error with _reql_timeout(timeout): await self._new_response.wait() # If there is a (non-empty) error to be received, we return True, so the # user will receive it on the next `next` call. return len(self.items) != 0
def fetch_next(self, wait=True): timeout = Cursor._wait_to_timeout(wait) waiter = reusable_waiter(self.conn._io_loop, timeout) while len(self.items) == 0 and self.error is None: self._maybe_fetch_batch() if self.error is not None: raise self.error with translate_timeout_errors(): yield from waiter(asyncio.shield(self.new_response)) # If there is a (non-empty) error to be received, we return True, so the # user will receive it on the next `next` call. return len(self.items) != 0 or not isinstance(self.error, RqlCursorEmpty)
def fetch_next(self, wait=True): timeout = Cursor._wait_to_timeout(wait) deadline = None if timeout is None else time.time() + timeout def wait_canceller(d): d.errback(ReqlTimeoutError()) while len(self.items) == 0 and self.error is None: self._maybe_fetch_batch() wait = Deferred(canceller=wait_canceller) self.waiting.append(wait) if deadline is not None: timeout = max(0, deadline - time.time()) reactor.callLater(timeout, lambda: wait.cancel()) yield wait returnValue(not self._is_empty() or self._has_error())
def __init__(self, *args, **kwargs): Cursor.__init__(self, *args, **kwargs) self.new_response = asyncio.Future()
def _extend(self, res_buf): Cursor._extend(self, res_buf) self.new_response.set_result(True) self.new_response = asyncio.Future()
def __init__(self, *args, **kwargs): ''' Constructor ''' self._new_response = trio.Event() self._nursery = kwargs.pop('nursery') Cursor.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): """ Constructor """ self._new_response = trio.Event() self._nursery = kwargs.pop("nursery") Cursor.__init__(self, *args, **kwargs)