Reduce default poll time and add DM ack clearing to standard poll

This commit is contained in:
Jack Kingsman
2026-02-23 20:00:42 -08:00
parent 7306627ac7
commit b9de3b7dd7
3 changed files with 12 additions and 7 deletions
+2 -2
View File
@@ -35,7 +35,7 @@ def track_pending_ack(expected_ack: str, message_id: int, timeout_ms: int) -> No
)
def _cleanup_expired_acks() -> None:
def cleanup_expired_acks() -> None:
"""Remove expired pending ACKs."""
now = time.time()
expired = []
@@ -268,7 +268,7 @@ async def on_ack(event: "Event") -> None:
logger.debug("Received ACK with code %s", ack_code)
_cleanup_expired_acks()
cleanup_expired_acks()
if ack_code in _pending_acks:
message_id, _, _ = _pending_acks.pop(ack_code)
+7 -2
View File
@@ -16,6 +16,7 @@ from contextlib import asynccontextmanager
from meshcore import EventType
from app.event_handlers import cleanup_expired_acks
from app.models import Contact
from app.radio import RadioOperationBusyError, radio_manager
from app.repository import (
@@ -31,8 +32,8 @@ logger = logging.getLogger(__name__)
# Message poll task handle
_message_poll_task: asyncio.Task | None = None
# Message poll interval in seconds
MESSAGE_POLL_INTERVAL = 5
# Message poll interval in seconds (10s gives DM ACKs plenty of time to arrive)
MESSAGE_POLL_INTERVAL = 10
# Periodic advertisement task handle
_advert_task: asyncio.Task | None = None
@@ -323,6 +324,10 @@ async def _message_poll_loop():
try:
await asyncio.sleep(MESSAGE_POLL_INTERVAL)
# Clean up expired pending ACKs every poll cycle so they don't
# accumulate when no ACKs arrive (e.g. all recipients out of range).
cleanup_expired_acks()
if radio_manager.is_connected and not is_polling_paused():
mc = radio_manager.meshcore
if mc is not None: