-
Notifications
You must be signed in to change notification settings - Fork 22
Open
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 fix(pkg-r):
querychat_app()should only close connections if it creates the DB #164 (R implementation)
Metadata
Metadata
Assignees
Labels
No labels