From a6443637833c7fbbd198d009ea8cb6371e3dd5ae Mon Sep 17 00:00:00 2001 From: AAGaming Date: Wed, 13 Jul 2022 23:24:29 -0400 Subject: [PATCH] fix get_tabs oopsie --- backend/injector.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/injector.py b/backend/injector.py index 9b4fe3536..ddccdf8f8 100644 --- a/backend/injector.py +++ b/backend/injector.py @@ -33,8 +33,10 @@ async def _send_devtools_cmd(self, dc, receive=True): return (await self.websocket.receive_json()) if receive else None raise RuntimeError("Websocket not opened") - async def evaluate_js(self, js, run_async=False): - await self.open_websocket() + async def evaluate_js(self, js, run_async=False, manage_socket=True): + if manage_socket: + await self.open_websocket() + res = await self._send_devtools_cmd({ "id": 1, "method": "Runtime.evaluate", @@ -45,7 +47,8 @@ async def evaluate_js(self, js, run_async=False): } }) - await self.client.close() + if manage_socket: + await self.client.close() return res async def get_steam_resource(self, url): @@ -72,7 +75,7 @@ async def get_tabs(): r = await res.json() return [Tab(i) for i in r] else: - raise Exception(f"/json did not return 200. {await r.text()}") + raise Exception(f"/json did not return 200. {await res.text()}") async def get_tab(tab_name): tabs = await get_tabs()