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__(
315
315
list (res .values ())[0 ], ** kwargs
316
316
)
317
317
self ._initialize = True
318
- self ._lock = asyncio .Lock ()
318
+ self ._lock : Optional [ asyncio .Lock ] = None
319
319
320
320
async def initialize (self ) -> "RedisCluster" :
321
321
"""Get all nodes from startup nodes & creates connections if not initialized."""
322
322
if self ._initialize :
323
+ if not self ._lock :
324
+ self ._lock = asyncio .Lock ()
323
325
async with self ._lock :
324
326
if self ._initialize :
325
327
try :
@@ -337,6 +339,8 @@ async def initialize(self) -> "RedisCluster":
337
339
async def close (self ) -> None :
338
340
"""Close all connections & client if initialized."""
339
341
if not self ._initialize :
342
+ if not self ._lock :
343
+ self ._lock = asyncio .Lock ()
340
344
async with self ._lock :
341
345
if not self ._initialize :
342
346
self ._initialize = True
You can’t perform that action at this time.
0 commit comments