client.py 文件源码

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

项目:aioautomatic 作者: armills 项目源码 文件源码
def ws_close(self):
        """Close the websocket connection."""
        if not self.ws_connected:
            return

        # Try to gracefully end the connection
        try:
            yield from self._ws_connection.send_str('41')
            yield from self._ws_connection.send_str('1')
        except (ClientError, HttpProcessingError, asyncio.TimeoutError):
            pass

        # Close any remaining ping handles
        handle = self._ws_session_data.get(ATTR_PING_INTERVAL_HANDLE)
        if handle:
            handle.cancel()
        handle = self._ws_session_data.get(ATTR_PING_TIMEOUT_HANDLE)
        if handle:
            handle.cancel()

        yield from self._ws_connection.close()
        self._ws_connection = None
        self._ws_session_data = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号