Skip to content

Commit 21e4df1

Browse files
authored
Merge pull request #97 from cloudblue/fix/LITE-25903
LITE-25903 `cqrs_sync` is more DB failure tolerant
2 parents e4305c4 + e65eed1 commit 21e4df1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

dj_cqrs/management/commands/cqrs_sync.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from django.core.exceptions import FieldError
1111
from django.core.management.base import BaseCommand, CommandError
12+
from django.db import close_old_connections
1213

1314
import ujson
1415

@@ -69,6 +70,7 @@ def handle(self, *args, **options):
6970
for qs_ in batch_qs(model.relate_cqrs_serialization(qs), batch_size=batch_size):
7071
ts = time.time()
7172
cs = counter
73+
7274
for instance in qs_:
7375
counter += 1
7476
try:
@@ -78,6 +80,7 @@ def handle(self, *args, **options):
7880
print('\nSync record failed for pk={0}: {1}: {2}'.format(
7981
instance.pk, type(e).__name__, str(e),
8082
))
83+
close_old_connections()
8184

8285
if progress:
8386
rate = (counter - cs) / (time.time() - ts)

0 commit comments

Comments
 (0)