ADD:lock
Showing
1 changed file
with
3 additions
and
1 deletions
... | @@ -10,6 +10,7 @@ import traceback | ... | @@ -10,6 +10,7 @@ import traceback |
10 | from collections import Counter | 10 | from collections import Counter |
11 | from datetime import datetime, date | 11 | from datetime import datetime, date |
12 | from django import db | 12 | from django import db |
13 | from django.db import transaction | ||
13 | from django.utils import timezone | 14 | from django.utils import timezone |
14 | from django.core.management import BaseCommand | 15 | from django.core.management import BaseCommand |
15 | from multiprocessing import Process, Queue, Manager, Lock | 16 | from multiprocessing import Process, Queue, Manager, Lock |
... | @@ -2034,7 +2035,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -2034,7 +2035,8 @@ class Command(BaseCommand, LoggerMixin): |
2034 | result_class = HILOCRResult if is_ca else HILSEOCRResult | 2035 | result_class = HILOCRResult if is_ca else HILSEOCRResult |
2035 | else: | 2036 | else: |
2036 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult | 2037 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult |
2037 | res_obj = result_class.objects.filter(application_id=doc.application_id).first() | 2038 | res_obj = result_class.objects.select_for_update().filter(application_id=doc.application_id).first() |
2039 | with transaction.atomic(): | ||
2038 | if res_obj is None: | 2040 | if res_obj is None: |
2039 | res_obj = result_class() | 2041 | res_obj = result_class() |
2040 | res_obj.application_id = doc.application_id | 2042 | res_obj.application_id = doc.application_id | ... | ... |
-
Please register or sign in to post a comment