Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Commit d95f07c

Browse files
Fix
1 parent 703511f commit d95f07c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mars/oscar/backends/router.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class Router:
3030
"_mapping",
3131
"_comm_config",
3232
"_cache_local",
33-
"_lock",
3433
)
3534

3635
_instance: "Router" = None
@@ -64,7 +63,6 @@ def __init__(
6463
self._mapping = mapping
6564
self._comm_config = comm_config or dict()
6665
self._cache_local = threading.local()
67-
self._lock = asyncio.Lock()
6866

6967
@property
7068
def _cache(self) -> Dict[Tuple[str, Any, Optional[Type[Client]]], Client]:
@@ -74,6 +72,14 @@ def _cache(self) -> Dict[Tuple[str, Any, Optional[Type[Client]]], Client]:
7472
cache = self._cache_local.cache = dict()
7573
return cache
7674

75+
@property
76+
def _lock(self) -> asyncio.Lock:
77+
try:
78+
return self._cache_local.lock
79+
except AttributeError:
80+
lock = self._cache_local.lock = asyncio.Lock()
81+
return lock
82+
7783
def set_mapping(self, mapping: Dict[str, str]):
7884
self._mapping = mapping
7985
self._cache_local = threading.local()

0 commit comments

Comments
 (0)