Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tofarr committed Nov 21, 2024
1 parent ac21f14 commit 13b7219
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions openhands/server/session/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def _redis_subscribe(self):
elif message_type == "restart":
connection_id = data["connection_id"]
if self.local_connection_id_to_session_id.get(connection_id) == sid:
self.init_or_join_session(sid, connection_id, data["settings"])
await self.init_or_join_session(sid, connection_id, data["settings"])
except asyncio.CancelledError:
return
except:
Expand Down Expand Up @@ -175,14 +175,21 @@ async def _close_orphaned_session(self, session: Session, force: bool):
if redis_client:
key = _CONNECTION_KEY.format(sid=session.sid)
redis_connections = await redis_client.lrange(key, 0, -1)
redis_connections = [
c.decode() for c in redis_connections
]
if not redis_connections:
await redis_client.delete(key)

redis_connections = [
c for c in redis_connections
if c not in self.local_connection_id_to_session_id
]

if force and redis_connections:
await redis_client.publish("oh_event", json.dumps({
"sid": session.sid,
"message_type": "restart",
"connection_id": redis_connections[0].decode(),
"connection_id": redis_connections[0],
"settings": session.settings,
}))

Expand Down

0 comments on commit 13b7219

Please sign in to comment.