print log when account available for queue

Этот коммит содержится в:
Vlad Pronsky 2023-07-30 15:15:47 +03:00
родитель 8f28bd1258
Коммит a378a9721e

Просмотреть файл

@ -250,17 +250,20 @@ class AccountsPool:
return Account.from_rs(rs) if rs else None return Account.from_rs(rs) if rs else None
async def get_for_queue_or_wait(self, queue: str) -> Account: async def get_for_queue_or_wait(self, queue: str) -> Account:
msg_show = False msg_shown = False
while True: while True:
account = await self.get_for_queue(queue) account = await self.get_for_queue(queue)
if not account: if not account:
if not msg_show: if not msg_shown:
nat = await self.next_available_at(queue) nat = await self.next_available_at(queue)
msg = f'No account available for queue "{queue}". Next available at {nat}' msg = f'No account available for queue "{queue}". Next available at {nat}'
logger.info(msg) logger.info(msg)
msg_show = True msg_shown = True
await asyncio.sleep(5) await asyncio.sleep(5)
continue continue
else:
if msg_shown:
logger.info(f"Account available for queue {queue}")
return account return account