From 72260dc90fc63ff3877fdf5e1170a41e67085841 Mon Sep 17 00:00:00 2001 From: Egor Matveev Date: Mon, 22 Nov 2021 21:30:29 +0300 Subject: [PATCH] sleep at transaction --- Main/management/commands/receive.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Main/management/commands/receive.py b/Main/management/commands/receive.py index c520639..cc13e28 100644 --- a/Main/management/commands/receive.py +++ b/Main/management/commands/receive.py @@ -1,3 +1,5 @@ +from time import sleep + import pika from django.core.management.base import BaseCommand @@ -19,11 +21,12 @@ class Command(BaseCommand): try: id = int(str(body, encoding='utf-8')) print(f"Received id {id}") - solution = Solution.objects.get(id=id) - except Exception as e: - print(e) - return - try: + while True: + try: + solution = Solution.objects.get(id=id) + break + except: + sleep(.5) eval(solution.language.work_name + 'Tester')(solution).execute() except Exception as e: print(e)