distributed-computing/tasks/nasybullov-ai/lab_4/python4Lab/Tut3/emit_log.py

12 lines
442 B
Python
Raw Permalink Normal View History

2024-01-09 18:57:58 +04:00
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='MytarinLogs', exchange_type='fanout')
message = ' '.join(sys.argv[1:]) or "Info: Hello I Mytarin ISEbd-41!"
channel.basic_publish(exchange='MytarinLogs', routing_key='', body=message)
print(f" [x] Отправлено сообщение: {message}")
connection.close()