ЛР 5: очередь и асинхронная обработка изображений

This commit is contained in:
2026-11-11 19:59:42 +03:00
parent 276dbdad8a
commit af485c93d4
54 changed files with 1966 additions and 34 deletions
+18
View File
@@ -0,0 +1,18 @@
"""Persistent, confirmed RabbitMQ messages contain identifiers only."""
import os
from pathlib import Path
import pika
QUEUE = 'attachments.v1'
def connect():
url = Path(os.environ['BROKER_URL_FILE']).read_text().strip()
params = pika.URLParameters(url)
params.heartbeat = 0 # one bounded image at a time; connection failure causes redelivery
params.socket_timeout = 5
params.blocked_connection_timeout = 10
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue=QUEUE, durable=True)
channel.confirm_delivery()
return connection, channel