Skip to content

Commit

Permalink
monkeypatch deduplication
Browse files Browse the repository at this point in the history
  • Loading branch information
betaboon committed Mar 17, 2021
1 parent 166854d commit 30b85b8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions aioairctrl/coap/aiocoap_monkeypatch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import asyncio
import functools

import aiocoap
from aiocoap import error
from aiocoap.numbers.constants import EXCHANGE_LIFETIME


def _deduplicate_message(self, message):
key = (message.remote, message.mid)
self.log.debug("MP: New unique message received")
self.loop.call_later(EXCHANGE_LIFETIME, functools.partial(self._recent_messages.pop, key))
self._recent_messages[key] = None
return False


aiocoap.messagemanager.MessageManager._deduplicate_message = _deduplicate_message


def __del__(self):
Expand Down

0 comments on commit 30b85b8

Please sign in to comment.