testers
This commit is contained in:
parent
a47563d7c1
commit
2ee9f1ea3b
@ -3,6 +3,7 @@ from shutil import rmtree
|
|||||||
|
|
||||||
import pika
|
import pika
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
from pika.adapters.utils.connection_workflow import AMQPConnectionWorkflowFailed
|
||||||
|
|
||||||
from Main.models import Solution
|
from Main.models import Solution
|
||||||
from Sprint import settings
|
from Sprint import settings
|
||||||
@ -14,6 +15,8 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
print("Enter worker")
|
print("Enter worker")
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
connection = pika.BlockingConnection(
|
connection = pika.BlockingConnection(
|
||||||
pika.ConnectionParameters(host=settings.RABBIT_HOST)
|
pika.ConnectionParameters(host=settings.RABBIT_HOST)
|
||||||
)
|
)
|
||||||
@ -37,3 +40,5 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
channel.basic_consume(queue="test", on_message_callback=callback, auto_ack=True)
|
channel.basic_consume(queue="test", on_message_callback=callback, auto_ack=True)
|
||||||
channel.start_consuming()
|
channel.start_consuming()
|
||||||
|
except AMQPConnectionWorkflowFailed:
|
||||||
|
print("connection to rabbit failed: reconnecting")
|
||||||
|
Loading…
Reference in New Issue
Block a user