Commit bff03e4d by baiquan

refactor(service): 优化关闭浏览器逻辑

- 将关闭浏览器的逻辑包裹在 try-except块中,提高异常处理的健壮性
parent 4a8724ee
...@@ -99,12 +99,12 @@ async def closeBrowser(browser_id): ...@@ -99,12 +99,12 @@ async def closeBrowser(browser_id):
data = { data = {
'containerCode': browser_id, 'containerCode': browser_id,
} }
try:
browser_status = await checkBrowserStatus(browser_id) browser_status = await checkBrowserStatus(browser_id)
browser_status_data = browser_status.get('data', {}) browser_status_data = browser_status.get('data', {})
if browser_status_data: if browser_status_data:
containers = browser_status_data.get('containers', {}) containers = browser_status_data.get('containers', {})
if containers: if containers:
try:
if (containers[0]['status'] == 1 or containers[0]['status'] == 0) and containers[0]['containerCode'] == browser_id: if (containers[0]['status'] == 1 or containers[0]['status'] == 0) and containers[0]['containerCode'] == browser_id:
return await sendRequest("POST", url=url, json_data=data) return await sendRequest("POST", url=url, json_data=data)
except Exception as e: except Exception as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment