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: handle periodic cleanup for sessions #3627

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

mscolnick
Copy link
Contributor

@mscolnick mscolnick commented Jan 30, 2025

This may help #3623, but I have not tested yet.

I will test this manually in the meantime, and try to make a reliable test out of it.

Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2025 7:49pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
marimo-storybook ⬜️ Ignored (Inspect) Visit Preview Jan 30, 2025 7:49pm

akshayka
akshayka previously approved these changes Jan 30, 2025
Comment on lines +1070 to +1071
@debounce(60)
def cleanup_orphaned_sessions(self) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Perplexing bug; I would have thought that

if self.manager.mode == SessionMode.RUN:
# When the websocket is closed, we wait session.ttl_seconds before
# closing the session. This is to prevent the session from being
# closed if the during an intermittent network issue.
def _close() -> None:
if self.status != ConnectionState.OPEN:
LOGGER.debug(
"Closing session %s (TTL EXPIRED)",
self.session_id,
)
# wait until TTL is expired before calling the cleanup
# function
cleanup_fn()
self.manager.close_session(self.session_id)
session = self.manager.get_session(self.session_id)
if session is not None:
cancellation_handle = asyncio.get_event_loop().call_later(
session.ttl_seconds, _close
)
self.cancel_close_handle = cancellation_handle

handled this case. Unless somehow the websocket's on_disconnect is not called?

@mscolnick
Copy link
Contributor Author

womp - all these tests work locally. none work in CI

@mscolnick mscolnick marked this pull request as draft January 31, 2025 15:43
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