client.py 文件源码

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

项目:aioautomatic 作者: armills 项目源码 文件源码
def _ws_loop(self):
        """Run the websocket loop listening for messages."""
        msg = None
        try:
            while True:
                msg = yield from self._ws_connection.receive()
                if msg.type == aiohttp.WSMsgType.TEXT:
                    self._handle_packet(msg.data)
                elif msg.type == aiohttp.WSMsgType.CLOSED:
                    break
                elif msg.type == aiohttp.WSMsgType.ERROR:
                    break
        except (ClientError, HttpProcessingError, asyncio.TimeoutError) as exc:
            raise exceptions.TransportError from exc
        finally:
            yield from self.ws_close()
            self._handle_event(EVENT_WS_CLOSED, None)
            if msg is not None and msg.type == aiohttp.WSMsgType.ERROR:
                raise exceptions.TransportError(
                    'Websocket error detected. Connection closed.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号