异常捕获后释放资源
This commit is contained in:
parent
d29b3e300f
commit
88343b7761
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue