异常捕获后释放资源

This commit is contained in:
ljun62 2023-05-24 15:23:31 +08:00
parent d29b3e300f
commit 88343b7761
1 changed files with 61 additions and 61 deletions

View File

@ -16,7 +16,6 @@ by UltrafunkAmsterdam (https://github.com/ultrafunkamsterdam)
"""
from __future__ import annotations
__version__ = "3.4.7"
import json
@ -46,7 +45,6 @@ from .reactor import Reactor
from .webelement import UCWebElement
from .webelement import WebElement
__all__ = (
"Chrome",
"ChromeOptions",
@ -449,7 +447,7 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
break
else:
service = None
try:
super(Chrome, self).__init__(
executable_path=self.patcher.executable_path,
port=port,
@ -460,6 +458,9 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
keep_alive=keep_alive,
service=service, # needed or the service will be re-created
)
except Exception:
self.quit()
raise
self.reactor = None
@ -766,7 +767,6 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
original = super().__getattribute__(item)
if inspect.ismethod(original) and not inspect.isclass(original):
def newfunc(*args, **kwargs):
logger.debug(
"calling %s with args %s and kwargs %s\n"