@@ -114,7 +114,7 @@ def from_url(
114
114
cls ,
115
115
url : str ,
116
116
single_connection_client : bool = False ,
117
- auto_close_connection_pool : bool = True ,
117
+ auto_close_connection_pool : Optional [ bool ] = None ,
118
118
** kwargs ,
119
119
):
120
120
"""
@@ -164,12 +164,17 @@ class initializer. In the case of conflicting arguments, querystring
164
164
connection_pool = connection_pool ,
165
165
single_connection_client = single_connection_client ,
166
166
)
167
- # We should probably deprecate the `auto_close_connection_pool`
168
- # argument.
169
- # If the caller doesn't want the pool auto-closed, a better
170
- # pattern is to create the pool manually (maybe using from_url()),
171
- # pass it in using the `connection_pool`, and hold on to it to close
172
- # it later.
167
+ if auto_close_connection_pool is not None :
168
+ warnings .warn (
169
+ DeprecationWarning (
170
+ "'auto_close_connection_pool' is deprecated "
171
+ "since version 5.0.0. "
172
+ "Please create a ConnectionPool explicitly and "
173
+ "provide to the Redis() constructor instead."
174
+ )
175
+ )
176
+ else :
177
+ auto_close_connection_pool = True
173
178
client .auto_close_connection_pool = auto_close_connection_pool
174
179
return client
175
180
@@ -223,7 +228,7 @@ def __init__(
223
228
username : Optional [str ] = None ,
224
229
retry : Optional [Retry ] = None ,
225
230
# deprecated. create a pool and use connection_pool instead
226
- auto_close_connection_pool : bool = True ,
231
+ auto_close_connection_pool : Optional [ bool ] = None ,
227
232
redis_connect_func = None ,
228
233
credential_provider : Optional [CredentialProvider ] = None ,
229
234
protocol : Optional [int ] = 2 ,
@@ -237,6 +242,18 @@ def __init__(
237
242
"""
238
243
kwargs : Dict [str , Any ]
239
244
245
+ if auto_close_connection_pool is not None :
246
+ warnings .warn (
247
+ DeprecationWarning (
248
+ "'auto_close_connection_pool' is deprecated "
249
+ "since version 5.0.0. "
250
+ "Please create a ConnectionPool explicitly and "
251
+ "provide to the Redis() constructor instead."
252
+ )
253
+ )
254
+ else :
255
+ auto_close_connection_pool = True
256
+
240
257
if not connection_pool :
241
258
# Create internal connection pool, expected to be closed by Redis instance
242
259
if not retry_on_error :
0 commit comments