25 lines
938 B
Python
25 lines
938 B
Python
import pika
|
|
import time
|
|
|
|
def publish_events():
|
|
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost', port=5672, credentials=pika.PlainCredentials("superuser", "superpassword")))
|
|
channel = connection.channel()
|
|
|
|
channel.exchange_declare(exchange='ml_events', exchange_type='fanout')
|
|
|
|
events = [
|
|
"Пользователь начал обучение модели",
|
|
"Модель закончила обучение",
|
|
"Пользователь запросил создание чекпоинта для модели",
|
|
"Пользователь запустил модель для infere"
|
|
]
|
|
|
|
while True:
|
|
event = events[int(time.time()) % len(events)]
|
|
channel.basic_publish(exchange='ml_events', routing_key='', body=event)
|
|
print(f'Отправлено: {event}')
|
|
time.sleep(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
publish_events() |