File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -315,11 +315,13 @@ def __init__(
315315 list (res .values ())[0 ], ** kwargs
316316 )
317317 self ._initialize = True
318- self ._lock = asyncio .Lock ()
318+ self ._lock : Optional [ asyncio .Lock ] = None
319319
320320 async def initialize (self ) -> "RedisCluster" :
321321 """Get all nodes from startup nodes & creates connections if not initialized."""
322322 if self ._initialize :
323+ if not self ._lock :
324+ self ._lock = asyncio .Lock ()
323325 async with self ._lock :
324326 if self ._initialize :
325327 try :
@@ -337,6 +339,8 @@ async def initialize(self) -> "RedisCluster":
337339 async def close (self ) -> None :
338340 """Close all connections & client if initialized."""
339341 if not self ._initialize :
342+ if not self ._lock :
343+ self ._lock = asyncio .Lock ()
340344 async with self ._lock :
341345 if not self ._initialize :
342346 self ._initialize = True
You can’t perform that action at this time.
0 commit comments