removed transaction

This commit is contained in:
Egor Matveev 2021-12-19 13:20:58 +03:00
parent f066336e11
commit c19f2609f4
2 changed files with 3 additions and 12 deletions

View File

@ -1,5 +1,3 @@
from time import sleep
import pika import pika
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
@ -20,15 +18,10 @@ class Command(BaseCommand):
channel.queue_declare(queue="test") channel.queue_declare(queue="test")
def callback(ch, method, properties, body): def callback(ch, method, properties, body):
id = int(str(body, encoding="utf-8"))
print(f"Received id {id}")
solution = Solution.objects.get(id=id)
try: try:
id = int(str(body, encoding="utf-8"))
print(f"Received id {id}")
while True:
try:
solution = Solution.objects.get(id=id)
break
except:
sleep(0.5)
eval(solution.language.work_name + "Tester")(solution).execute() eval(solution.language.work_name + "Tester")(solution).execute()
except Exception as e: except Exception as e:
print(e) print(e)

View File

@ -1,6 +1,5 @@
from typing import Optional from typing import Optional
from django.db import transaction
from django.core.handlers.wsgi import WSGIRequest from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponseRedirect, JsonResponse from django.http import HttpResponseRedirect, JsonResponse
from django.shortcuts import render from django.shortcuts import render
@ -23,7 +22,6 @@ class BaseView:
@classmethod @classmethod
def as_view(cls): def as_view(cls):
@transaction.atomic
def execute(request): def execute(request):
if request.user.is_authenticated: if request.user.is_authenticated:
user_info = request.user.userinfo user_info = request.user.userinfo