mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 00:55:50 +00:00
Enhancement: Ensure proper DB connection management in Celery tasks by checking for worker context before releasing connections, preventing potential ORM errors.
This commit is contained in:
parent
810a7a93a1
commit
dff97d9067
1 changed files with 3 additions and 0 deletions
|
|
@ -36,6 +36,7 @@ from core.utils import (
|
|||
send_websocket_update,
|
||||
cleanup_memory,
|
||||
log_system_event,
|
||||
_is_celery_worker_context,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -100,6 +101,8 @@ _NON_TERMINAL_REFRESH_STATUSES = frozenset({
|
|||
|
||||
def _release_task_db_connection():
|
||||
"""Return the Celery worker's DB connection to a clean state after ORM errors."""
|
||||
if not _is_celery_worker_context():
|
||||
return
|
||||
from django.db import close_old_connections
|
||||
close_old_connections()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue