Skip to content

Commit d33b9f0

Browse files
authored
Merge pull request #94 from pokliu/fix-async-lock-concurrency
Fix async concurrency by replacing threading.RLock with asyncio.Lock
2 parents 96ab151 + fd480e2 commit d33b9f0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

py_eureka_client/eureka_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def __init__(self,
396396
assert ha_strategy in (HA_STRATEGY_RANDOM, HA_STRATEGY_STICK,
397397
HA_STRATEGY_OTHER) if should_discover else True, f"do not support strategy {ha_strategy}"
398398

399-
self.__net_lock = RLock()
399+
self.__net_lock = asyncio.Lock()
400400
self.__eureka_server_conf = EurekaServerConf(
401401
eureka_server=eureka_server,
402402
eureka_domain=eureka_domain,
@@ -634,7 +634,7 @@ async def __try_all_eureka_servers(self, fun):
634634
await self.__try_eureka_server_regardless_zones(fun)
635635

636636
async def __try_eureka_servers_in_list(self, fun, eureka_servers=[], zone=_DEFAUTL_ZONE):
637-
with self.__net_lock:
637+
async with self.__net_lock:
638638
ok = False
639639
_zone = zone if zone else _DEFAUTL_ZONE
640640
for url in eureka_servers:

0 commit comments

Comments
 (0)