From 1789aee1e7ed0d240afab9914e2ae4bd0c775a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Tue, 29 Sep 2020 16:16:47 +0200 Subject: [PATCH] Added "connection.close" to release used connections early" (fixed) --- server/src/uds/core/jobs/delayed_task_runner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/uds/core/jobs/delayed_task_runner.py b/server/src/uds/core/jobs/delayed_task_runner.py index bd2a9523..dba73b95 100644 --- a/server/src/uds/core/jobs/delayed_task_runner.py +++ b/server/src/uds/core/jobs/delayed_task_runner.py @@ -37,7 +37,7 @@ from socket import gethostname from datetime import timedelta from django.db import connections -from django.db import transaction, connection +from django.db import transaction from django.db.models import Q from uds.models import DelayedTask as DBDelayedTask @@ -152,7 +152,7 @@ class DelayedTaskRunner: except Exception as e: logger.info('Exception inserting a delayed task %s: %s', e.__class__, e) try: - connection.close() + connections['default'].close() except Exception: logger.exception('Closing db connection at insert') time.sleep(1) # Wait a bit before next try... @@ -190,7 +190,7 @@ class DelayedTaskRunner: except Exception as e: logger.error('Unexpected exception at run loop %s: %s', e.__class__, e) try: - connection.close() + connections['default'].close() except Exception: logger.exception('Exception clossing connection at delayed task') logger.info('Exiting DelayedTask Runner because stop has been requested')