plotly / plotly/dash

Allow a "cleanup" callback that is executed when a session ends

Open
#2,346 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.