Skip to content

Commit 1b5f61d

Browse files
committed
update
1 parent 6655382 commit 1b5f61d

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

utils/ReptileUtil.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,24 @@ def is_element_present(driver, by, value):
218218
return True
219219

220220

221+
def _quit(driver):
222+
"""
223+
结束进程
224+
:param driver:
225+
:return:
226+
"""
227+
driver.quit()
228+
# os.system('taskkill /im chromedriver.exe /F')
229+
# Service.stop()
230+
# try:
231+
# import signal
232+
# pid = driver.service.process.pid
233+
# os.kill(int(pid), signal.SIGTERM)
234+
# print("Killed chrome using process")
235+
# except ProcessLookupError as ex:
236+
# pass
237+
238+
221239
class SafeDriver:
222240
def __init__(self, url, debug=False):
223241
self.driver = selenium_driver(url, debug)
@@ -227,22 +245,11 @@ def __enter__(self):
227245

228246
def __exit__(self, exc_type, exc_val, exc_tb):
229247
if self.driver:
230-
# os.system('taskkill /im chromedriver.exe /F')
231-
self.driver.quit()
232-
Service.stop()
248+
_quit(self.driver)
233249

234250
def __del__(self):
235251
if self.driver:
236-
# os.system('taskkill /im chromedriver.exe /F')
237-
self.driver.quit()
238-
Service.stop()
239-
try:
240-
import signal
241-
pid = driver.service.process.pid
242-
os.kill(int(pid), signal.SIGTERM)
243-
print("Killed chrome using process")
244-
except ProcessLookupError as ex:
245-
pass
252+
_quit(self.driver)
246253

247254

248255
if __name__ == '__main__':

0 commit comments

Comments
 (0)