connection.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:aredis 作者: NoneGG 项目源码 文件源码
def read_response(self):
        if not self._stream:
            raise ConnectionError("Socket closed on remote end")

        # _next_response might be cached from a can_read() call
        if self._next_response is not False:
            response = self._next_response
            self._next_response = False
            return response

        response = self._reader.gets()
        while response is False:
            try:
                buffer = await self._stream.read(self._read_size)
            # CancelledError will be caught by client so that command won't be retried again
            # For more detailed discussion please see https://github.com/NoneGG/aredis/issues/56
            except CancelledError:
                raise
            except Exception:
                e = sys.exc_info()[1]
                raise ConnectionError("Error {} while reading from stream: {}".format(type(e), e.args))
            if not buffer:
                raise ConnectionError("Socket closed on remote end")
            self._reader.feed(buffer)
            response = self._reader.gets()
        if isinstance(response, ResponseError):
            response = self.parse_error(response.args[0])
        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号