ЛР 5: очередь и асинхронная обработка изображений
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user