Skip to content

Commit

Permalink
pin to master
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Aug 15, 2024
1 parent 42fbdd3 commit 857e072
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions onadata/apps/restservice/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"""
restservice async functions.
"""
from multidb.pinning import use_master

from onadata.apps.logger.models.instance import Instance
from onadata.apps.restservice.utils import call_service
from onadata.celeryapp import app
Expand All @@ -12,17 +14,18 @@ def call_service_async(instance_pk, latest_json=None):
"""Async function that calls call_service()."""
# load the parsed instance

try:
instance = Instance.objects.get(pk=instance_pk)
except Instance.DoesNotExist:
# if the instance has already been removed we do not send it to the
# service
pass
else:
if latest_json is None:
instance.json = instance.get_full_dict()
with use_master:
try:
instance = Instance.objects.get(pk=instance_pk)
except Instance.DoesNotExist:
# if the instance has already been removed we do not send it to the
# service
return

else:
instance.json = latest_json
if latest_json is None:
instance.json = instance.get_full_dict()

else:
instance.json = latest_json

call_service(instance)
call_service(instance)

0 comments on commit 857e072

Please sign in to comment.