Skip to content

Commit

Permalink
[py]: simplify service kwarg handling in the service base class
Browse files Browse the repository at this point in the history
  • Loading branch information
symonk committed Mar 11, 2023
1 parent 005b588 commit 393ba87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions py/CHANGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Selenium 4.8.3
* More fine grained control for `Service` subprocesses is now available via passing a `popen_kw` keyed map to any `Service` instance.
* `Service` classes can now control `close_fds` and `creationflags` via `**kwargs` on any `Service` instance.
* Setting `timeouts` on an `Options` instance no longer raises an exception for subsets of supported timeouts. (#11623)
* Add fine grained control for arguments provided to service subprocesses by passing a `popen_kw` mapping for all services.
* `Options` classes now allow `timeout` to be set partially and no longer raise an exception when all values are not provided. (#11623)
* No longer sending `SIGKILL` to subprocesses in instances where `SIGTERM` was successful within 60 seconds.

Selenium 4.8.2
Expand Down
8 changes: 4 additions & 4 deletions py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ def __init__(
self.log_file = open(os.devnull, "wb") if not _HAS_NATIVE_DEVNULL and log_file == DEVNULL else log_file
self.start_error_message = start_error_message or ""
# Default value for every python subprocess: subprocess.Popen(..., creationflags=0)
self.creation_flags = kwargs.pop("creation_flags", 0)
self.close_fds = kwargs.pop("close_fds") or system() != "Windows"
self.env = env or os.environ
self.popen_kw = kwargs.pop("popen_kw", {})
self.creation_flags = self.popen_kw.pop("creation_flags", 0)
self.env = env or os.environ

@property
def service_url(self) -> str:
Expand Down Expand Up @@ -199,11 +198,12 @@ def _start_process(self, path: str) -> None:
"""
cmd = [path]
cmd.extend(self.command_line_args())
close_file_descriptors = self.popen_kw.pop("close_fds") or system() != "Windows"
try:
self.process = subprocess.Popen(
cmd,
env=self.env,
close_fds=self.close_fds,
close_fds=close_file_descriptors,
stdout=self.log_file,
stderr=self.log_file,
stdin=PIPE,
Expand Down

0 comments on commit 393ba87

Please sign in to comment.