This commit is contained in:
Egor Matveev
2022-05-12 16:09:48 +03:00
parent 08de8a05f8
commit 38fa241e90
5 changed files with 36 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ from django.contrib.auth.models import User
from django.core.management import BaseCommand
import psycopg2
import django.db
import django.db.utils
from pika.adapters.utils.connection_workflow import AMQPConnectorException
from Sprint import settings
@@ -35,7 +36,7 @@ class MessagingSupport(BaseCommand):
try:
self.process(data)
print("Process finished successfully")
except (psycopg2.OperationalError, django.db.OperationalError):
except (psycopg2.OperationalError, django.db.OperationalError, django.db.utils.OperationalError):
print("Failed to connect to database, restarting...")
send_to_queue(self.queue_name, data)
raise

View File

@@ -6,6 +6,7 @@ from django.core.management import BaseCommand
from requests import get, post
from Sprint import settings
from SprintLib.queue import send_to_queue
def write_bytes(data: bytes):
@@ -67,3 +68,9 @@ class LoopWorker(BaseCommand):
while True:
self.go()
sleep(self.sleep_period)
def send_testing(solution):
if solution.set is not None and len(solution.set.checkers.all()) != 0:
return
send_to_queue("test", {"id": solution.id})