This commit is contained in:
Egor Matveev
2022-03-15 21:12:45 +03:00
parent cdf5787b41
commit 76a74efbe7
2 changed files with 12 additions and 9 deletions

View File

@@ -7,18 +7,16 @@ from pika.adapters.utils.connection_workflow import AMQPConnectorException
from Sprint import settings
def send_testing(solution):
if solution.set is not None and len(solution.set.checkers.all()) != 0:
return
def send_to_queue(queue_name, payload):
with pika.BlockingConnection(
pika.ConnectionParameters(host=settings.RABBIT_HOST, port=settings.RABBIT_PORT)
) as connection:
channel = connection.channel()
channel.queue_declare(queue="test")
channel.queue_declare(queue=queue_name)
channel.basic_publish(
exchange="",
routing_key="test",
body=json.dumps({"id": solution.id}).encode('utf-8'),
routing_key=queue_name,
body=json.dumps(payload).encode('utf-8'),
)