mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-10 07:18:10 -05:00
Fix Bash commands now do not block and actually respect the timeout (#4058)
This commit is contained in:
@@ -323,7 +323,13 @@ class RuntimeClient:
|
||||
logger.debug('Requesting exit code...')
|
||||
self.shell.expect(self.__bash_expect_regex, timeout=timeout)
|
||||
_exit_code_output = self.shell.before
|
||||
exit_code = int(_exit_code_output.strip().split()[0])
|
||||
try:
|
||||
exit_code = int(_exit_code_output.strip().split()[0])
|
||||
except:
|
||||
logger.error('Error getting exit code from bash script')
|
||||
# If we try to run an invalid shell script the output sometimes includes error text
|
||||
# rather than the error code - we assume this is an error
|
||||
exit_code = 2
|
||||
|
||||
except pexpect.TIMEOUT as e:
|
||||
if kill_on_timeout:
|
||||
@@ -622,7 +628,7 @@ if __name__ == '__main__':
|
||||
observation = await client.run_action(action)
|
||||
return event_to_dict(observation)
|
||||
except Exception as e:
|
||||
logger.error(f'Error processing command: {str(e)}')
|
||||
logger.error(f'Error processing command: {str(e)}', exc_info=True, stack_info=True)
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.post('/upload_file')
|
||||
|
||||
@@ -162,6 +162,9 @@ class Session:
|
||||
'Model does not support image upload, change to a different model or try without an image.'
|
||||
)
|
||||
return
|
||||
asyncio.run_coroutine_threadsafe(self._add_event(event, EventSource.USER), self.agent_session.loop) # type: ignore
|
||||
|
||||
async def _add_event(self, event, event_source):
|
||||
self.agent_session.event_stream.add_event(event, EventSource.USER)
|
||||
|
||||
async def send(self, data: dict[str, object]) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user