Fix race condition in Matter unsubscribe method (#103770)
This commit is contained in:
parent
818bc12f87
commit
0e4186ff8a
1 changed files with 4 additions and 1 deletions
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from abc import abstractmethod
|
||||
from collections.abc import Callable
|
||||
from contextlib import suppress
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
@ -110,7 +111,9 @@ class MatterEntity(Entity):
|
|||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Run when entity will be removed from hass."""
|
||||
for unsub in self._unsubscribes:
|
||||
unsub()
|
||||
with suppress(ValueError):
|
||||
# suppress ValueError to prevent race conditions
|
||||
unsub()
|
||||
|
||||
@callback
|
||||
def _on_matter_event(self, event: EventType, data: Any = None) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue