示例#1
0
 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))
示例#2
0
 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
示例#3
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)
示例#4
0
    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())