khoj
khoj copied to clipboard
Fix database connections leakage (#980)
Description
This pull request addresses a database connection leak caused by django-apscheduler
not closing stale connections after task execution. The solution involves wrapping run_with_process_lock
with the @close_old_connections
decorator provided by django-apscheduler
.
For more details, refer to the django-apscheduler documentation on database connections and timeouts.
Changes
- Added
@close_old_connections
decorator torun_with_process_lock
to ensure database connections are properly closed after each scheduled task.
Related Issue
- Fixes #980: Database connections not closed after scheduled tasks, leading to connection leakage.