Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix session leak #5656

Merged
merged 1 commit into from
Dec 17, 2024
Merged

fix session leak #5656

merged 1 commit into from
Dec 17, 2024

Conversation

rbren
Copy link
Collaborator

@rbren rbren commented Dec 17, 2024

End-user friendly description of the problem this fixes or functionality that this introduces

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below
    CHANGELOG: Fixed an issue where sessions sometimes don't close properly, causing memory and FD leaks

Give a summary of what the PR does, explaining any non-trivial design decisions

Make sure the session finishes initializing before closing it


Link of any specific issues this addresses


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:43b06c1-nikolaik   --name openhands-app-43b06c1   docker.all-hands.dev/all-hands-ai/openhands:43b06c1

Comment on lines +154 to +165
seconds_waited = 0
while self._initializing:
logger.debug(
f'Waiting for initialization to finish before closing session {self.sid}'
)
await asyncio.sleep(WAIT_TIME_BEFORE_CLOSE_INTERVAL)
seconds_waited += WAIT_TIME_BEFORE_CLOSE_INTERVAL
if seconds_waited > WAIT_TIME_BEFORE_CLOSE:
logger.error(
f'Waited too long for initialization to finish before closing session {self.sid}'
)
break
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main fix

Copy link
Collaborator

@tofarr tofarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎂 🥮 🍰

@rbren rbren merged commit 6ae84bf into main Dec 17, 2024
15 checks passed
@rbren rbren deleted the rb/fix-leak branch December 17, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants