[Python] Add automatic connection `cleanup`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reading the Python cleanup requirements in this issue and the related R implementation in PR #164. Investigate whether Python Shiny provides the required on_stop() lifecycle hook, then identify the QueryChat Python cleanup entry points and tests. Done means safe ownership rules, Shiny-session cleanup, R/Python consistency, and user documentation.
Written by the indexing model from the issue text.
Description
Summary
This issue tracks the implementation of automatic connection cleanup in QueryChat for Python, building on the R implementation discussed in PR #164.
Background
PR #164 adds a cleanup parameter to QueryChat's R implementation with automatic cleanup behavior when:
- A connection is created by QueryChat (e.g., for a data frame)
- The QueryChat object is used within a Shiny app session via
on_stop()/onStop()callbacks
Problem Statement
Python's Shiny framework does not yet have an equivalent of R's shiny::onStop() callback mechanism that allows for application-level cleanup. This prevents us from:
- Automatically cleaning up connections when QueryChat exits a Shiny app
- Keeping the R/Python cleanup logic in sync
- Providing consistent behavior across both implementations
Key Considerations
- Connection Ownership: Only clean up connections that QueryChat created or explicitly manages, not connections provided by users, unless the QueryChat object is created inside a Shiny app context
- Safety First: Avoid destructive actions when a connection is used outside of a Shiny app context
- Predictable Behavior: Simple, clear rules about when cleanup happens (not relying on
interactive()or other implicit signals) - Consistency: R and Python implementations should follow similar logic
Next Steps
- Implement
on_stop()in Shiny for Python (equivalent to R'sshiny::onStop()) - Once available, add Python support for automatic cleanup with similar logic to the R implementation
- Document when and how cleanup occurs for users
Related
- PR #164 (R implementation)
- Dominant language
- Python
- Stars
- 212
- Forks
- 29
- Avg merge
- 18h 45m
- Merged PRs (30d)
- 24
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from posit-dev/querychat
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
R: handoff pill lost on history restore — blocked on shinychat-r UI message state (shinychat#311)Open
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
posit-dev/querychat#270 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
posit-dev/querychat#269 · 1 comment ·
Maintainers usually reply within 1 day
All issues in posit-dev/querychat
Similar issues
-
enhancement P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Toloka/tolokaforge#1776 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
TencentCloud/Octop#1622 ·
Maintainers usually reply within 1 day
-
Independent PhaseMap objects share and leak their default mode groupingPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Rust: `const _` gets its file's node ID, so the file node is relabelled `_` and gains a self-loopOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Graphify-Labs/graphify#4064 · 1 comment ·
Maintainers usually reply within 2 days