Skip to content

Commit 8048d84

Browse files
fix: fallback_cache func
1 parent 2263190 commit 8048d84

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

roborock/util.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import asyncio
44
import functools
55
from asyncio import AbstractEventLoop
6-
from typing import Optional, TypeVar
6+
from typing import Any, Awaitable, Callable, Optional, TypeVar
77

88
T = TypeVar("T")
99

@@ -39,14 +39,13 @@ class CacheableResult:
3939

4040

4141
def fallback_cache():
42-
_run_sync = run_sync()
4342
cache = CacheableResult()
4443

45-
def decorator(func):
44+
def decorator(func: Callable[[Any, Any], Awaitable[Any]]):
4645
@functools.wraps(func)
47-
def wrapped(*args, **kwargs):
46+
async def wrapped(*args, **kwargs):
4847
try:
49-
cache.last_run_result = _run_sync(func(*args, **kwargs))
48+
cache.last_run_result = await func(*args, **kwargs)
5049
except Exception as e:
5150
if cache.last_run_result is None:
5251
raise e

0 commit comments

Comments
 (0)