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 @@ -356,11 +356,13 @@ def __init__(
356356 )
357357
358358 self ._initialize = True
359- self ._lock = asyncio .Lock ()
359+ self ._lock : Optional [ asyncio .Lock ] = None
360360
361361 async def initialize (self ) -> "RedisCluster" :
362362 """Get all nodes from startup nodes & creates connections if not initialized."""
363363 if self ._initialize :
364+ if not self ._lock :
365+ self ._lock = asyncio .Lock ()
364366 async with self ._lock :
365367 if self ._initialize :
366368 try :
@@ -378,6 +380,8 @@ async def initialize(self) -> "RedisCluster":
378380 async def close (self ) -> None :
379381 """Close all connections & client if initialized."""
380382 if not self ._initialize :
383+ if not self ._lock :
384+ self ._lock = asyncio .Lock ()
381385 async with self ._lock :
382386 if not self ._initialize :
383387 self ._initialize = True
You can’t perform that action at this time.
0 commit comments