def _extend(self, res): Cursor._extend(self, res) 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))
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 _extend(self, res): Cursor._extend(self, res) self.new_response.set_result(True) self.new_response = Future()
def __init__(self, *args, **kwargs): Cursor.__init__(self, *args, **kwargs) self.new_response = Future()
def _extend(self, res_buf): Cursor._extend(self, res_buf) self.new_response.set_result(True) self.new_response = asyncio.Future()