aio-pika icon indicating copy to clipboard operation
aio-pika copied to clipboard

should I make a hard connection in my app?

Open yangjinhao1234 opened this issue 2 years ago • 0 comments

I see the doc, I know the connection class is the beginning of the aio-pika. but I don't know if the connection is designed to be a reuseable one?

could I make a connection and reuse it anywhere like this ?

class publisher:
    _instance=None
    def __new__(cls):
        if not cls._instance:
            cls._instance=super().__new__(cls)
        return cls._instance
    
	async def initialize(url):
        self.__connection=aio-pika.connect(url)
        
    @property
    def connection():
        return self.__connection

yangjinhao1234 avatar May 09 '22 01:05 yangjinhao1234