Don't retry respond_peers message (#3508)

This commit is contained in:
Mariano Sorgente 2021-05-03 18:58:17 +09:00 committed by GitHub
parent ca4b25210b
commit 5ce1bfc34c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -238,7 +238,7 @@ class WSChiaConnection:
self.log.error(f"Exception Stack: {error_stack}")
async def send_message(self, message: Message):
""" Send message sends a message with no tracking / callback. """
"""Send message sends a message with no tracking / callback."""
if self.closed:
return
await self.outgoing_queue.put(message)
@ -346,13 +346,16 @@ class WSChiaConnection:
f"peer: {self.peer_host}"
)
async def wait_and_retry(msg: Message, queue: asyncio.Queue):
try:
await asyncio.sleep(1)
await queue.put(msg)
except Exception as e:
self.log.debug(f"Exception {e} while waiting to retry sending rate limited message")
return
# TODO: fix this special case. This function has rate limits which are too low.
if ProtocolMessageTypes(message.type) != ProtocolMessageTypes.respond_peers:
async def wait_and_retry(msg: Message, queue: asyncio.Queue):
try:
await asyncio.sleep(1)
await queue.put(msg)
except Exception as e:
self.log.debug(f"Exception {e} while waiting to retry sending rate limited message")
return
asyncio.create_task(wait_and_retry(message, self.outgoing_queue))
return