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'):