Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing out logging on quit #12637

Merged
merged 4 commits into from
Sep 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from abc import ABC
from abc import abstractmethod
from platform import system
from subprocess import DEVNULL
from subprocess import PIPE
from time import sleep
from typing import TextIO
from urllib import request
from urllib.error import URLError

Expand Down Expand Up @@ -141,13 +141,12 @@ def send_remote_shutdown_command(self) -> None:

def stop(self) -> None:
"""Stops the service."""
if self.log_output != PIPE and not (self.log_output == DEVNULL):
try:
# Todo: Be explicit in what we are catching here.
if hasattr(self.log_output, "close"):
self.log_file.close() # type: ignore
except Exception:
pass

if self.log_output != PIPE:
if isinstance(self.log_output, TextIO):
self.log_output.close()
elif isinstance(self.log_output, int):
os.close(self.log_output)

if self.process is not None:
try:
Expand Down