4.1.0.8修复一个headers设置问题;修复多线程关闭tab时可能报错问题

This commit is contained in:
g1879 2024-10-14 23:44:56 +08:00
parent b854df764c
commit 6a3918756e
3 changed files with 14 additions and 13 deletions

View File

@ -12,4 +12,4 @@ from ._pages.chromium_page import ChromiumPage
from ._pages.session_page import SessionPage from ._pages.session_page import SessionPage
from ._pages.web_page import WebPage from ._pages.web_page import WebPage
__version__ = '4.1.0.7' __version__ = '4.1.0.8'

View File

@ -396,15 +396,16 @@ class Chromium(object):
pass pass
def _onTargetDestroyed(self, **kwargs): def _onTargetDestroyed(self, **kwargs):
tab_id = kwargs['targetId'] with self._lock:
self._dl_mgr.clear_tab_info(tab_id) tab_id = kwargs['targetId']
for key in [k for k, i in self._frames.items() if i == tab_id]: self._dl_mgr.clear_tab_info(tab_id)
self._frames.pop(key, None) for key in [k for k, i in self._frames.items() if i == tab_id]:
for d in self._all_drivers.get(tab_id, tuple()): self._frames.pop(key, None)
d.stop() for d in self._all_drivers.get(tab_id, tuple()):
self._drivers.pop(tab_id, None) d.stop()
self._all_drivers.pop(tab_id, None) self._drivers.pop(tab_id, None)
self._tab_to_close.discard(tab_id) self._all_drivers.pop(tab_id, None)
self._tab_to_close.discard(tab_id)
def _on_disconnect(self): def _on_disconnect(self):
if not self._disconnect_flag: if not self._disconnect_flag:

View File

@ -302,10 +302,10 @@ def tree(ele_or_page, text=False, show_js=False, show_css=False):
def format_headers(txt): def format_headers(txt):
if isinstance(txt, (dict, CaseInsensitiveDict)): if isinstance(txt, (dict, CaseInsensitiveDict)):
for k, v in txt.items(): for k, v in txt.items():
if k in (':method', ':scheme', ':authority', ':path'): if v not in (None, False, True):
txt.pop(k)
elif v not in (None, False, True):
txt[k] = str(v) txt[k] = str(v)
for i in (':method', ':scheme', ':authority', ':path'):
txt.pop(i, None)
return txt return txt
headers = {} headers = {}
for header in txt.split('\n'): for header in txt.split('\n'):