Browse Source

Fix for regression (#4075)

Regression fixed
tofarr 1 year ago
parent
commit
c919086e25

+ 0 - 2
openhands/controller/agent_controller.py

@@ -119,8 +119,6 @@ class AgentController:
 
     async def close(self):
         """Closes the agent controller, canceling any ongoing tasks and unsubscribing from the event stream."""
-        if self.agent_task is not None:
-            self.agent_task.cancel()
         await self.set_agent_state_to(AgentState.STOPPED)
         self.event_stream.unsubscribe(EventStreamSubscriber.AGENT_CONTROLLER)
 

+ 2 - 1
openhands/server/session/agent_session.py

@@ -32,6 +32,7 @@ class AgentSession:
     runtime: Runtime | None = None
     security_analyzer: SecurityAnalyzer | None = None
     _closed: bool = False
+    loop: asyncio.AbstractEventLoop
 
     def __init__(self, sid: str, file_store: FileStore):
         """Initializes a new instance of the Session class
@@ -44,6 +45,7 @@ class AgentSession:
         self.sid = sid
         self.event_stream = EventStream(sid, file_store)
         self.file_store = file_store
+        self.loop = asyncio.new_event_loop()
 
     async def start(
         self,
@@ -71,7 +73,6 @@ class AgentSession:
                 'Session already started. You need to close this session and start a new one.'
             )
 
-        self.loop = asyncio.new_event_loop()
         self.thread = Thread(target=self._run, daemon=True)
         self.thread.start()