我有以下代码:
class Singleton:
__instance = None
connection = None
@staticmethod
def getInstance(loop):
if Singleton.__instance == None:
Singleton(loop)
return Singleton.__instance
def __init__(self, loop):
Singleton.__instance = self
Singleton.connection = aio_pika.connect_robust(config.MQ_BROKER_URL, loop=loop)
对于每个传入请求,我都以这种方式等待连接:
mq_connection = await Singleton.getInstance(asyncio.get_event_loop()).connection
我收到此错误:
RuntimeError: cannot reuse already awaited coroutine
问题: