__init__.py 文件源码

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

项目:ChromeHeadlessInterface 作者: wilson9x1 项目源码 文件源码
def recv_by_special_id(self, command_id=None):

        if command_id:
            expected_id = command_id
        else:
            expected_id = self._command_id

        ws_result = []
        ws_instance = self._tab.get("ws_instance")

        while True:
            try:
                result = ws_instance.recv()
            except websocket.WebSocketTimeoutException:
                return ws_result

            if self._debug:
                print("[DEBUG] result: {0}".format(result))
            if not result:
                return ws_result

            # ????
            ws_result.append(result)

            # ?????????
            formatted_result = json.loads(result)
            event_name = formatted_result.get("method")
            params = formatted_result.get("params")
            self._call_event_listener(event_name, params)

            # ??????
            if int(formatted_result.get("id", 0)) == expected_id-1:
                break
        return ws_result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号