Skip to content
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/service-library/src/servicelib/rabbitmq/_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import logging
import os
import socket
from typing import Any, Final

import aio_pika
import psutil
from aiormq.exceptions import ChannelPreconditionFailed
from pydantic import NonNegativeInt
from tenacity import retry
Expand Down Expand Up @@ -51,7 +53,13 @@ async def wait_till_rabbitmq_responsive(url: str) -> bool:


def get_rabbitmq_client_unique_name(base_name: str) -> str:
return f"{base_name}_{socket.gethostname()}"
# NOTE: below prefix is guaranteed to change each time the preocess restarts
# Why is this desiarable?
# 1. the code base makes the above assumption, otherwise subcscribers and consumers do not work
# 2. enables restartability of webserver during [re]deploys
prefix_create_time = f"{psutil.Process(os.getpid()).create_time()}".strip(".")[-6:]

return f"{base_name}_{socket.gethostname()}_{prefix_create_time}"


async def declare_queue(
Expand Down