From d270aaeef72d8a65fb9a7bb03c8df41ddfcc582b Mon Sep 17 00:00:00 2001 From: HA-Master-User Date: Fri, 13 Mar 2026 10:09:28 +0100 Subject: [PATCH] Update messagemanager.py Prevent AttributeError during shutdown when _active_exchanges has already been cleared. This can happen when shutdown is triggered more than once and the code tries to iterate over None. --- aiocoap/messagemanager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aiocoap/messagemanager.py b/aiocoap/messagemanager.py index b6a36727..b89b44a5 100644 --- a/aiocoap/messagemanager.py +++ b/aiocoap/messagemanager.py @@ -70,11 +70,13 @@ def __repr__(self): getattr(self, "message_interface", "(unbound)"), ) - @property + @property def client_credentials(self): return self.token_manager.client_credentials async def shutdown(self): + if self._active_exchanges is None: + return for messageerror_monitor, cancellable in self._active_exchanges.values(): # Not calling messageerror_monitor: This is not message specific, # and its shutdown will take care of these things