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

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qianduoduo0904 committed Dec 8, 2022
1 parent 703511f commit d95f07c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mars/oscar/backends/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Router:
"_mapping",
"_comm_config",
"_cache_local",
"_lock",
)

_instance: "Router" = None
Expand Down Expand Up @@ -64,7 +63,6 @@ def __init__(
self._mapping = mapping
self._comm_config = comm_config or dict()
self._cache_local = threading.local()
self._lock = asyncio.Lock()

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

@property
def _lock(self) -> asyncio.Lock:
try:
return self._cache_local.lock
except AttributeError:
lock = self._cache_local.lock = asyncio.Lock()
return lock

def set_mapping(self, mapping: Dict[str, str]):
self._mapping = mapping
self._cache_local = threading.local()
Expand Down

0 comments on commit d95f07c

Please sign in to comment.