feat: misc bash improvements, set max value for action-exec timeout, retry on requests.ConnectionError (#6175)

This commit is contained in:
Xingyao Wang 2025-01-10 15:36:12 -05:00 committed by GitHub
parent 828d169b82
commit f31ccad48b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 14 deletions

View File

@ -67,6 +67,13 @@ class Event:
@timeout.setter
def timeout(self, value: int | None) -> None:
self._timeout = value
if value is not None and value > 600:
from openhands.core.logger import openhands_logger as logger
logger.warning(
'Timeout greater than 600 seconds may not be supported by '
'the runtime. Consider setting a lower timeout.'
)
# Check if .blocking is an attribute of the event
if hasattr(self, 'blocking'):

View File

@ -486,18 +486,6 @@ class BashSession:
last_change_time = start_time
last_pane_output = self._get_pane_content()
_ps1_matches = CmdOutputMetadata.matches_ps1_metadata(last_pane_output)
assert len(_ps1_matches) >= 1, (
'Expected at least one PS1 metadata block BEFORE the execution of a command, '
f'but got {len(_ps1_matches)} PS1 metadata blocks:\n---\n{last_pane_output!r}\n---'
)
if len(_ps1_matches) > 1:
logger.warning(
'Found multiple PS1 metadata blocks BEFORE the execution of a command. '
'Only the last one will be used.'
)
_ps1_matches = [_ps1_matches[-1]]
if command != '':
# convert command to raw string
command = escape_bash_special_chars(command)

View File

@ -21,7 +21,7 @@ class RequestHTTPError(requests.HTTPError):
return s
def is_rate_limit_error(exception):
def is_retryable_error(exception):
return (
isinstance(exception, requests.HTTPError)
and exception.response.status_code == 429
@ -29,7 +29,7 @@ def is_rate_limit_error(exception):
@retry(
retry=retry_if_exception(is_rate_limit_error),
retry=retry_if_exception(is_retryable_error),
stop=stop_after_attempt(3) | stop_if_should_exit(),
wait=wait_exponential(multiplier=1, min=4, max=60),
)

View File

@ -101,6 +101,7 @@ reportlab = "*"
[tool.coverage.run]
concurrency = ["gevent"]
[tool.poetry.group.runtime.dependencies]
jupyterlab = "*"
notebook = "*"
@ -129,6 +130,7 @@ ignore = ["D1"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.poetry.group.evaluation.dependencies]
streamlit = "*"
whatthepatch = "*"