Skip to content

Commit 8ac4e72

Browse files
fix: possible solution for future invalid state
1 parent 9008470 commit 8ac4e72

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

roborock/roborock_future.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ def __init__(self, protocol: int):
1414
self.fut: Future = Future()
1515
self.loop = self.fut.get_loop()
1616

17+
def _resolve(self, item: tuple[Any, VacuumError | None]) -> None:
18+
if not self.fut.cancelled():
19+
self.fut.set_result(item)
20+
1721
def resolve(self, item: tuple[Any, VacuumError | None]) -> None:
18-
self.loop.call_soon_threadsafe(self.fut.set_result, item)
22+
self.loop.call_soon_threadsafe(self._resolve, item)
1923

2024
async def async_get(self, timeout: float | int) -> tuple[Any, VacuumError | None]:
2125
try:

0 commit comments

Comments
 (0)