Esempio n. 1
0
    def get(self, timeout=None):
        try:
            return super(GeventFuture, self).get(timeout=timeout)
        except NotImplementedError:
            pass

        try:
            return self.async_result.get(timeout=timeout)
        except gevent.Timeout as e:
            raise Timeout(e)
Esempio n. 2
0
    def get(self, timeout=None):
        try:
            return super(ThreadingFuture, self).get(timeout=timeout)
        except NotImplementedError:
            pass

        try:
            if self._data is None:
                self._data = self._queue.get(True, timeout)
            if 'exc_info' in self._data:
                _compat.reraise(*self._data['exc_info'])
            else:
                return self._data['value']
        except _compat.queue.Empty:
            raise Timeout('{} seconds'.format(timeout))
Esempio n. 3
0
    def get(self, timeout=None):
        try:
            return super(EventletFuture, self).get(timeout=timeout)
        except NotImplementedError:
            pass

        if timeout is not None:
            wait_timeout = eventlet.Timeout(timeout)
            try:
                with wait_timeout:
                    return self.event.wait()
            except eventlet.Timeout as t:
                if t is not wait_timeout:
                    raise
                raise Timeout(t)
        else:
            return self.event.wait()
Esempio n. 4
0
    def get(self, timeout=None) -> ThreadingFutureResult:
        try:
            return super().get(timeout=timeout)

        except NotImplementedError:
            pass

        # 处理特殊情况.
        try:
            if self._result is None:
                self._result = self._queue.get(True, timeout)
            # remove some exc_trace_info
            else:
                return self._result.value

        except queue.Empty:
            raise Timeout(f"{timeout} seconds")