state_delta_subscription_handler.py 文件源码

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

项目:sawtooth-core 作者: hyperledger 项目源码 文件源码
def subscriptions(self, request):
        """
        Handles requests for new subscription websockets.

        Args:
            request (aiohttp.Request): the incoming request

        Returns:
            aiohttp.web.WebSocketResponse: the websocket response, when the
                resulting websocket is closed
        """

        if not self._accepting:
            return web.Response(status=503)

        web_sock = web.WebSocketResponse()
        await web_sock.prepare(request)

        async for msg in web_sock:
            if msg.type == aiohttp.WSMsgType.TEXT:
                await self._handle_message(web_sock, msg.data)
            elif msg.type == aiohttp.WSMsgType.ERROR:
                LOGGER.warning(
                    'Web socket connection closed with exception %s',
                    web_sock.exception())
                await web_sock.close()

        await self._handle_unsubscribe(web_sock)

        return web_sock
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号