mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
add few seconds to properly receive timeout error from client
This commit is contained in:
committed by
Xingyao Wang
parent
9af6399a90
commit
61d99e9e37
@@ -417,7 +417,8 @@ class EventStreamRuntime(Runtime):
|
||||
response = self.session.post(
|
||||
f'{self.api_url}/execute_action',
|
||||
json={'action': event_to_dict(action)},
|
||||
timeout=action.timeout,
|
||||
# wait a few more seconds to get the timeout error from client side
|
||||
timeout=action.timeout + 5,
|
||||
)
|
||||
if response.status_code == 200:
|
||||
output = response.json()
|
||||
|
||||
@@ -41,6 +41,7 @@ from openhands.runtime.utils.request import (
|
||||
send_request,
|
||||
)
|
||||
from openhands.runtime.utils.runtime_build import build_runtime_image
|
||||
from openhands.utils.tenacity_stop import stop_if_should_exit
|
||||
|
||||
|
||||
class RemoteRuntime(Runtime):
|
||||
@@ -250,7 +251,8 @@ class RemoteRuntime(Runtime):
|
||||
'POST',
|
||||
f'{self.runtime_url}/execute_action',
|
||||
json=request_body,
|
||||
timeout=action.timeout,
|
||||
# wait a few more seconds to get the timeout error from client side
|
||||
timeout=action.timeout + 5,
|
||||
retry_exceptions=list(
|
||||
filter(lambda e: e != TimeoutError, DEFAULT_RETRY_EXCEPTIONS)
|
||||
),
|
||||
|
||||
@@ -57,6 +57,31 @@ def test_bash_command_pexcept(temp_dir, box_class, run_as_openhands):
|
||||
_close_test_runtime(runtime)
|
||||
|
||||
|
||||
def test_bash_timeout_and_keyboard_interrupt(temp_dir, box_class, run_as_openhands):
|
||||
runtime = _load_runtime(temp_dir, box_class, run_as_openhands)
|
||||
try:
|
||||
action = CmdRunAction(command='python -c "import time; time.sleep(10)"')
|
||||
action.timeout = 1
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert isinstance(obs, CmdOutputObservation)
|
||||
assert (
|
||||
'[Command timed out after 1 seconds. SIGINT was sent to interrupt it.]'
|
||||
in obs.content
|
||||
)
|
||||
assert 'KeyboardInterrupt' in obs.content
|
||||
|
||||
# follow up command should not be affected
|
||||
action = CmdRunAction(command='ls')
|
||||
action.timeout = 1
|
||||
obs = runtime.run_action(action)
|
||||
assert isinstance(obs, CmdOutputObservation)
|
||||
assert obs.exit_code == 0
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
finally:
|
||||
_close_test_runtime(runtime)
|
||||
|
||||
|
||||
def test_multiline_commands(temp_dir, box_class):
|
||||
runtime = _load_runtime(temp_dir, box_class)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user