Skip to content

Commit

Permalink
fix: prevent race condition in session manager during disconnect (#6053)
Browse files Browse the repository at this point in the history
Co-authored-by: openhands <[email protected]>
  • Loading branch information
rbren and openhands-agent authored Jan 10, 2025
1 parent 8907fed commit ee701ea
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions openhands/server/session/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,9 @@ async def _process_message(self, message: dict):
# which can't be guaranteed - nodes can simply vanish unexpectedly!
sid = data['sid']
logger.debug(f'session_closing:{sid}')
for (
connection_id,
local_sid,
) in self.local_connection_id_to_session_id.items():
# Create a list of items to process to avoid modifying dict during iteration
items = list(self.local_connection_id_to_session_id.items())
for connection_id, local_sid in items:
if sid == local_sid:
logger.warning(
'local_connection_to_closing_session:{connection_id}:{sid}'
Expand Down

0 comments on commit ee701ea

Please sign in to comment.