mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
微调逻辑
This commit is contained in:
parent
acc8a7fd6e
commit
b938a85c9a
@ -229,14 +229,15 @@ class Driver(object):
|
|||||||
self._ws.close()
|
self._ws.close()
|
||||||
self._ws = None
|
self._ws = None
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
while not self.event_queue.empty():
|
# while not self.event_queue.empty():
|
||||||
event = self.event_queue.get_nowait()
|
# event = self.event_queue.get_nowait()
|
||||||
function = self.event_handlers.get(event['method'])
|
# function = self.event_handlers.get(event['method'])
|
||||||
if function:
|
# if function:
|
||||||
function(**event['params'])
|
# function(**event['params'])
|
||||||
except:
|
# sleep(.1)
|
||||||
pass
|
# except:
|
||||||
|
# pass
|
||||||
|
|
||||||
self.event_handlers.clear()
|
self.event_handlers.clear()
|
||||||
self.method_results.clear()
|
self.method_results.clear()
|
||||||
|
@ -197,7 +197,8 @@ def raise_error(result, ignore=None):
|
|||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
error = result['error']
|
error = result['error']
|
||||||
if error in ('Cannot find context with specified id', 'Inspected target navigated or closed'):
|
if error in ('Cannot find context with specified id', 'Inspected target navigated or closed',
|
||||||
|
'No frame with given id found'):
|
||||||
r = ContextLostError()
|
r = ContextLostError()
|
||||||
elif error in ('Could not find node with given id', 'Could not find object with given id',
|
elif error in ('Could not find node with given id', 'Could not find object with given id',
|
||||||
'No node with given id found', 'Node with given id does not belong to the document',
|
'No node with given id found', 'Node with given id does not belong to the document',
|
||||||
@ -221,9 +222,8 @@ def raise_error(result, ignore=None):
|
|||||||
r = RuntimeError(f'你的浏览器可能太旧。\n方法:{result["method"]}\n参数:{result["args"]}')
|
r = RuntimeError(f'你的浏览器可能太旧。\n方法:{result["method"]}\n参数:{result["args"]}')
|
||||||
elif result['type'] in ('call_method_error', 'timeout'):
|
elif result['type'] in ('call_method_error', 'timeout'):
|
||||||
from DrissionPage import __version__
|
from DrissionPage import __version__
|
||||||
from time import process_time
|
|
||||||
txt = f'\n错误:{result["error"]}\n方法:{result["method"]}\n参数:{result["args"]}\n' \
|
txt = f'\n错误:{result["error"]}\n方法:{result["method"]}\n参数:{result["args"]}\n' \
|
||||||
f'版本:{__version__}\n运行时间:{process_time()}\n出现这个错误可能意味着程序有bug,请把错误信息和重现方法' \
|
f'版本:{__version__}\n出现这个错误可能意味着程序有bug,请把错误信息和重现方法' \
|
||||||
'告知作者,谢谢。\n报告网站:https://gitee.com/g1879/DrissionPage/issues'
|
'告知作者,谢谢。\n报告网站:https://gitee.com/g1879/DrissionPage/issues'
|
||||||
r = TimeoutError(txt) if result['type'] == 'timeout' else CDPError(txt)
|
r = TimeoutError(txt) if result['type'] == 'timeout' else CDPError(txt)
|
||||||
else:
|
else:
|
||||||
|
@ -168,9 +168,13 @@ class ChromiumBase(BasePage):
|
|||||||
result = True
|
result = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
except PageDisconnectedError:
|
||||||
|
result = False
|
||||||
|
break
|
||||||
except:
|
except:
|
||||||
timeout = end_time - perf_counter()
|
timeout = end_time - perf_counter()
|
||||||
timeout = .5 if timeout <= 0 else timeout
|
timeout = .5 if timeout <= 0 else timeout
|
||||||
|
sleep(.1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
result = False
|
result = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user