Exemplo n.º 1
0
    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)
Exemplo n.º 2
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))
Exemplo n.º 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)
Exemplo n.º 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())
Exemplo n.º 5
0
 def _extend(self, res):
     Cursor._extend(self, res)
     self.new_response.set_result(True)
     self.new_response = Future()
Exemplo n.º 6
0
 def __init__(self, *args, **kwargs):
     Cursor.__init__(self, *args, **kwargs)
     self.new_response = Future()
Exemplo n.º 7
0
 def _extend(self, res_buf):
     Cursor._extend(self, res_buf)
     self.new_response.set_result(True)
     self.new_response = asyncio.Future()