File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -356,11 +356,13 @@ def __init__(
356
356
)
357
357
358
358
self ._initialize = True
359
- self ._lock = asyncio .Lock ()
359
+ self ._lock : Optional [ asyncio .Lock ] = None
360
360
361
361
async def initialize (self ) -> "RedisCluster" :
362
362
"""Get all nodes from startup nodes & creates connections if not initialized."""
363
363
if self ._initialize :
364
+ if not self ._lock :
365
+ self ._lock = asyncio .Lock ()
364
366
async with self ._lock :
365
367
if self ._initialize :
366
368
try :
@@ -378,6 +380,8 @@ async def initialize(self) -> "RedisCluster":
378
380
async def close (self ) -> None :
379
381
"""Close all connections & client if initialized."""
380
382
if not self ._initialize :
383
+ if not self ._lock :
384
+ self ._lock = asyncio .Lock ()
381
385
async with self ._lock :
382
386
if not self ._initialize :
383
387
self ._initialize = True
You can’t perform that action at this time.
0 commit comments