Skip to content

Commit ba0dcea

Browse files
committed
set the auto_close_connection_pool flag on Redis instance with its own pool.
1 parent 28cc65c commit ba0dcea

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

redis/asyncio/sentinel.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,13 @@ def master_for(
335335
kwargs["is_master"] = True
336336
connection_kwargs = dict(self.connection_kwargs)
337337
connection_kwargs.update(kwargs)
338+
339+
connection_pool = connection_pool_class(service_name, self, **connection_kwargs)
340+
# The Redis object "owns" the pool
341+
auto_close_connection_pool = True
338342
return redis_class(
339-
connection_pool=connection_pool_class(
340-
service_name, self, **connection_kwargs
341-
)
343+
connection_pool=connection_pool,
344+
auto_close_connection_pool=auto_close_connection_pool,
342345
)
343346

344347
def slave_for(
@@ -368,8 +371,11 @@ def slave_for(
368371
kwargs["is_master"] = False
369372
connection_kwargs = dict(self.connection_kwargs)
370373
connection_kwargs.update(kwargs)
374+
375+
connection_pool = connection_pool_class(service_name, self, **connection_kwargs)
376+
# The Redis object "owns" the pool
377+
auto_close_connection_pool = True
371378
return redis_class(
372-
connection_pool=connection_pool_class(
373-
service_name, self, **connection_kwargs
374-
)
379+
connection_pool=connection_pool,
380+
auto_close_connection_pool=auto_close_connection_pool,
375381
)

0 commit comments

Comments
 (0)