Skip to content

Commit 5671bbb

Browse files
committed
Close connections after each task
This emulates the request_finished signal
1 parent 39ceb97 commit 5671bbb

File tree

1 file changed

+4
-0
lines changed
  • django_tasks/backends/database/management/commands

1 file changed

+4
-0
lines changed

django_tasks/backends/database/management/commands/db_worker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import List, Optional
99

1010
from django.core.management.base import BaseCommand
11+
from django.db import connections
1112
from django.db.utils import OperationalError
1213

1314
from django_tasks import DEFAULT_TASK_BACKEND_ALIAS, tasks
@@ -97,6 +98,9 @@ def start(self) -> None:
9798
finally:
9899
self.running_task = False
99100

101+
for conn in connections.all(initialized_only=True):
102+
conn.close()
103+
100104
if self.batch and task_result is None:
101105
# If we're running in "batch" mode, terminate the loop (and thus the worker)
102106
return None

0 commit comments

Comments
 (0)