fix: add request timeout and replace assert with proper exception
This commit is contained in:
1 parent
f0ff7ee49e
commit
af3ee66cd7
1 file changed
+3
-2
+3
-2
@@ -204,7 +204,8 @@ class TMWebDriver:
|
||||
raise ValueError(f"会话ID {session_id} 未连接")
|
||||
|
||||
tp = session.type
|
||||
assert tp in ['ws', 'http', 'ext_ws'], f"Unsupported session type: {tp}"
|
||||
if tp not in ('ws', 'http', 'ext_ws'):
|
||||
raise ValueError(f"Unsupported session type: {tp}")
|
||||
exec_id = str(uuid.uuid4())
|
||||
payload_dict = {'id': exec_id, 'code': code}
|
||||
if tp == 'ext_ws': payload_dict['tabId'] = int(session.id)
|
||||
@@ -243,7 +244,7 @@ class TMWebDriver:
|
||||
return rr
|
||||
|
||||
def _remote_cmd(self, cmd):
|
||||
try: return requests.post(self.remote, headers={"Content-Type": "application/json"}, json=cmd).json()
|
||||
try: return requests.post(self.remote, headers={"Content-Type": "application/json"}, json=cmd, timeout=30).json()
|
||||
except (ConnectionError, requests.exceptions.ConnectionError):
|
||||
raise ConnectionError("TMWebDriver master未运行,看tmwebdriver_sop启动master")
|
||||
|
||||
|
||||
Reference in new issue
Block a user