add possibility to increase stop service timeout
appium/webdriver/appium_service.py
please make timeout for self._process.communicate(timeout=5)
def stop(self, timeout=5) -> bool:
"""Stops Appium service if it is running.
The call will be ignored if the service is not running
or has been already stopped.
Returns:
`True` if the service was running before being stopped
"""
is_terminated = False
if self.is_running:
assert self._process
self._process.terminate()
self._process.communicate(timeout=timeout)
is_terminated = True
self._process = None
self._cmd = None
return is_terminated
as a method param
why not propose this as a PR?
And could you share the timeout case's Appium log? I'm curious about what situation caused over 5 sec to stop the process.
2024-09-23 12:49:48:719 [HTTP] Closing Appium HTTP server 2024-09-23 12:49:53:722 [HTTP] Not all active connections have been closed within 5001ms. Exiting anyway.
mac m3 48gb macos 16 sonoma
appium -v 2.11.4 [email protected]
speaking about PR - for sure i can provide it. but it pretty minor fix and i think that someone who already developing some features for python client can add this
https://github.com/appium/python-client/pull/1030
When I use the readme examples, I get the error below
@pytest.fixture(scope='session')
def appium_service():
service = AppiumService()
service.start(
# Check the output of appium server --help for the complete list of
# server command line arguments
args=['--address', APPIUM_HOST, '-p', str(APPIUM_PORT)],
timeout_ms=20000,
)
yield service
if service.is_running:
service.stop()
conftest.py:23:
../../Library/Caches/pypoetry/virtualenvs/appium-practice-u-JbVLem-py3.12/lib/python3.12/site-packages/appium/webdriver/appium_service.py:238: in stop self._process.communicate(timeout=5) ../../.pyenv/versions/3.12.0/lib/python3.12/subprocess.py:1209: in communicate stdout, stderr = self._communicate(input, endtime, timeout) ../../.pyenv/versions/3.12.0/lib/python3.12/subprocess.py:2109: in _communicate self._check_timeout(endtime, orig_timeout, stdout, stderr)
self = <Popen: returncode: None args: ['/Users/cengdong/.volta/bin/node', '/opt/hom...> endtime = 750225.915939083, orig_timeout = 5 stdout_seq = [b'\x1b[38;5;112m[Appium]\x1b[0m Welcome to Appium v2.11.5 (REV 916044581862c32fc2365e8e9ff0b1507a98925e)\n\x1b[38;5;1...92cd3b0]\x1b[0m\x1b[38;5;86m[HTTP]\x1b[0m <-- DELETE /session/792cd3b0-3133-4430-91a7-818884a9a37c 200 132 ms - 14 \n'] stderr_seq = [], skip_check_and_raise = False
def _check_timeout(self, endtime, orig_timeout, stdout_seq, stderr_seq,
skip_check_and_raise=False):
"""Convenience for checking if a timeout has expired."""
if endtime is None:
return
if skip_check_and_raise or _time() > endtime:
raise TimeoutExpired(
self.args, orig_timeout,
output=b''.join(stdout_seq) if stdout_seq else None,
stderr=b''.join(stderr_seq) if stderr_seq else None)
E subprocess.TimeoutExpired: Command '['/Users/cengdong/.volta/bin/node', '/opt/homebrew/lib/node_modules/appium/build/lib/main.js', '--address', '127.0.0.1', '-p', '4723']' timed out after 5 seconds
../../.pyenv/versions/3.12.0/lib/python3.12/subprocess.py:1253: TimeoutExpired
This already has in v4.1.1