浏览代码

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

Xingyao Wang 1 年之前
父节点
当前提交
d50425865a
共有 1 个文件被更改,包括 6 次插入12 次删除
  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':