Allow a "cleanup" callback that is executed when a session ends
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
It would be nice to have something like this, sort of the opposite of a serve_layout() function that gets executed with app.layout for every new session. This would allow, for example, server-side storing (e.g. using Redis) that would delete session data when the user disconnects.
def serve_layout():
user_id = uuid4()
redis_db[user_id] = <some data here>
...
return layout
app.layout = serve_layout
@dash.on_end_session
def cleanup_layout():
del redis_db[user_id]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests; start by tracing how app.layout creates per-session state and how Dash registers lifecycle callbacks. Investigate the session-disconnect mechanism and define the callback's registration, execution, and failure behavior, then add coverage showing that session data is cleaned up when a session ends.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, redis
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100