From 6a3918756ecd06164064a6bfe3ef9026b695da50 Mon Sep 17 00:00:00 2001 From: g1879 Date: Mon, 14 Oct 2024 23:44:56 +0800 Subject: [PATCH] =?UTF-8?q?4.1.0.8=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AAhead?= =?UTF-8?q?ers=E8=AE=BE=E7=BD=AE=E9=97=AE=E9=A2=98=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=A4=9A=E7=BA=BF=E7=A8=8B=E5=85=B3=E9=97=ADtab?= =?UTF-8?q?=E6=97=B6=E5=8F=AF=E8=83=BD=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/__init__.py | 2 +- DrissionPage/_base/chromium.py | 19 ++++++++++--------- DrissionPage/_functions/web.py | 6 +++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/DrissionPage/__init__.py b/DrissionPage/__init__.py index 65d5714..a7fc44d 100644 --- a/DrissionPage/__init__.py +++ b/DrissionPage/__init__.py @@ -12,4 +12,4 @@ from ._pages.chromium_page import ChromiumPage from ._pages.session_page import SessionPage from ._pages.web_page import WebPage -__version__ = '4.1.0.7' +__version__ = '4.1.0.8' diff --git a/DrissionPage/_base/chromium.py b/DrissionPage/_base/chromium.py index 20bb17d..096a88e 100644 --- a/DrissionPage/_base/chromium.py +++ b/DrissionPage/_base/chromium.py @@ -396,15 +396,16 @@ class Chromium(object): pass def _onTargetDestroyed(self, **kwargs): - tab_id = kwargs['targetId'] - self._dl_mgr.clear_tab_info(tab_id) - for key in [k for k, i in self._frames.items() if i == tab_id]: - self._frames.pop(key, None) - for d in self._all_drivers.get(tab_id, tuple()): - d.stop() - self._drivers.pop(tab_id, None) - self._all_drivers.pop(tab_id, None) - self._tab_to_close.discard(tab_id) + with self._lock: + tab_id = kwargs['targetId'] + self._dl_mgr.clear_tab_info(tab_id) + for key in [k for k, i in self._frames.items() if i == tab_id]: + self._frames.pop(key, None) + for d in self._all_drivers.get(tab_id, tuple()): + d.stop() + self._drivers.pop(tab_id, None) + self._all_drivers.pop(tab_id, None) + self._tab_to_close.discard(tab_id) def _on_disconnect(self): if not self._disconnect_flag: diff --git a/DrissionPage/_functions/web.py b/DrissionPage/_functions/web.py index d6061b7..f1a1f3d 100644 --- a/DrissionPage/_functions/web.py +++ b/DrissionPage/_functions/web.py @@ -302,10 +302,10 @@ def tree(ele_or_page, text=False, show_js=False, show_css=False): def format_headers(txt): if isinstance(txt, (dict, CaseInsensitiveDict)): for k, v in txt.items(): - if k in (':method', ':scheme', ':authority', ':path'): - txt.pop(k) - elif v not in (None, False, True): + if v not in (None, False, True): txt[k] = str(v) + for i in (':method', ':scheme', ':authority', ':path'): + txt.pop(i, None) return txt headers = {} for header in txt.split('\n'):