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 = None
|
||||
|
||||
try:
|
||||
while not self.event_queue.empty():
|
||||
event = self.event_queue.get_nowait()
|
||||
function = self.event_handlers.get(event['method'])
|
||||
if function:
|
||||
function(**event['params'])
|
||||
except:
|
||||
pass
|
||||
# try:
|
||||
# while not self.event_queue.empty():
|
||||
# event = self.event_queue.get_nowait()
|
||||
# function = self.event_handlers.get(event['method'])
|
||||
# if function:
|
||||
# function(**event['params'])
|
||||
# sleep(.1)
|
||||
# except:
|
||||
# pass
|
||||
|
||||
self.event_handlers.clear()
|
||||
self.method_results.clear()
|
||||
|
@ -197,7 +197,8 @@ def raise_error(result, ignore=None):
|
||||
:return: None
|
||||
"""
|
||||
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()
|
||||
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',
|
||||
@ -221,9 +222,8 @@ def raise_error(result, ignore=None):
|
||||
r = RuntimeError(f'你的浏览器可能太旧。\n方法:{result["method"]}\n参数:{result["args"]}')
|
||||
elif result['type'] in ('call_method_error', 'timeout'):
|
||||
from DrissionPage import __version__
|
||||
from time import process_time
|
||||
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'
|
||||
r = TimeoutError(txt) if result['type'] == 'timeout' else CDPError(txt)
|
||||
else:
|
||||
|
@ -168,9 +168,13 @@ class ChromiumBase(BasePage):
|
||||
result = True
|
||||
break
|
||||
|
||||
except PageDisconnectedError:
|
||||
result = False
|
||||
break
|
||||
except:
|
||||
timeout = end_time - perf_counter()
|
||||
timeout = .5 if timeout <= 0 else timeout
|
||||
sleep(.1)
|
||||
|
||||
else:
|
||||
result = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user