Explorar o código

fix(runtime): only accept one request at a time for exec action requests (#4589)

Xingyao Wang hai 1 ano
pai
achega
d50425865a
Modificáronse 1 ficheiros con 6 adicións e 12 borrados
  1. 6 12
      openhands/runtime/action_execution_server.py

+ 6 - 12
openhands/runtime/action_execution_server.py

@@ -159,11 +159,12 @@ class ActionExecutor:
         logger.debug('Bash init commands completed')
 
     async def run_action(self, action) -> Observation:
-        action_type = action.action
-        logger.debug(f'Running action:\n{action}')
-        observation = await getattr(self, action_type)(action)
-        logger.debug(f'Action output:\n{observation}')
-        return observation
+        async with self.lock:
+            action_type = action.action
+            logger.debug(f'Running action:\n{action}')
+            observation = await getattr(self, action_type)(action)
+            logger.debug(f'Action output:\n{observation}')
+            return observation
 
     async def run(
         self, action: CmdRunAction
@@ -372,13 +373,6 @@ if __name__ == '__main__':
             content={'message': 'Invalid request parameters', 'details': exc.errors()},
         )
 
-    @app.middleware('http')
-    async def one_request_at_a_time(request: Request, call_next):
-        assert client is not None
-        async with client.lock:
-            response = await call_next(request)
-        return response
-
     @app.middleware('http')
     async def authenticate_requests(request: Request, call_next):
         if request.url.path != '/alive' and request.url.path != '/server_info':