mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-08 17:53:10 +02:00
Don't consume DM resend attempt on busy radio
This commit is contained in:
@@ -421,7 +421,8 @@ async def _retry_direct_message_until_acked(
|
|||||||
message_repository,
|
message_repository,
|
||||||
) -> None:
|
) -> None:
|
||||||
next_wait_timeout_ms = wait_timeout_ms
|
next_wait_timeout_ms = wait_timeout_ms
|
||||||
for attempt in range(1, DM_SEND_MAX_ATTEMPTS):
|
attempt = 1
|
||||||
|
while attempt < DM_SEND_MAX_ATTEMPTS:
|
||||||
await sleep_fn((next_wait_timeout_ms / 1000) * DM_RETRY_WAIT_MARGIN)
|
await sleep_fn((next_wait_timeout_ms / 1000) * DM_RETRY_WAIT_MARGIN)
|
||||||
if await _is_message_acked(message_id=message_id, message_repository=message_repository):
|
if await _is_message_acked(message_id=message_id, message_repository=message_repository):
|
||||||
return
|
return
|
||||||
@@ -463,6 +464,14 @@ async def _retry_direct_message_until_acked(
|
|||||||
timestamp=sender_timestamp,
|
timestamp=sender_timestamp,
|
||||||
attempt=attempt,
|
attempt=attempt,
|
||||||
)
|
)
|
||||||
|
except RadioOperationBusyError:
|
||||||
|
logger.debug(
|
||||||
|
"Radio busy during DM retry attempt %d/%d for %s, will retry without consuming attempt",
|
||||||
|
attempt + 1,
|
||||||
|
DM_SEND_MAX_ATTEMPTS,
|
||||||
|
contact.public_key[:12],
|
||||||
|
)
|
||||||
|
continue
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"Background DM retry attempt %d/%d failed for %s",
|
"Background DM retry attempt %d/%d failed for %s",
|
||||||
@@ -470,6 +479,7 @@ async def _retry_direct_message_until_acked(
|
|||||||
DM_SEND_MAX_ATTEMPTS,
|
DM_SEND_MAX_ATTEMPTS,
|
||||||
contact.public_key[:12],
|
contact.public_key[:12],
|
||||||
)
|
)
|
||||||
|
attempt += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
@@ -479,6 +489,7 @@ async def _retry_direct_message_until_acked(
|
|||||||
DM_SEND_MAX_ATTEMPTS,
|
DM_SEND_MAX_ATTEMPTS,
|
||||||
contact.public_key[:12],
|
contact.public_key[:12],
|
||||||
)
|
)
|
||||||
|
attempt += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if result.type == EventType.ERROR:
|
if result.type == EventType.ERROR:
|
||||||
@@ -489,6 +500,7 @@ async def _retry_direct_message_until_acked(
|
|||||||
contact.public_key[:12],
|
contact.public_key[:12],
|
||||||
result.payload,
|
result.payload,
|
||||||
)
|
)
|
||||||
|
attempt += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if await _is_message_acked(message_id=message_id, message_repository=message_repository):
|
if await _is_message_acked(message_id=message_id, message_repository=message_repository):
|
||||||
@@ -516,6 +528,8 @@ async def _retry_direct_message_until_acked(
|
|||||||
if ack_count > 0:
|
if ack_count > 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
attempt += 1
|
||||||
|
|
||||||
|
|
||||||
async def send_direct_message_to_contact(
|
async def send_direct_message_to_contact(
|
||||||
*,
|
*,
|
||||||
|
|||||||
Reference in New Issue
Block a user