@@ -278,6 +278,17 @@ def __init__(
278278 single_connection_client:
279279 if `True`, connection pool is not used. In that case `Redis`
280280 instance use is not thread safe.
281+ decode_responses:
282+ if `True`, the response will be decoded to utf-8.
283+ Argument is ignored when connection_pool is provided.
284+ maint_notifications_config:
285+ configuration the pool to support maintenance notifications - see
286+ `redis.maint_notifications.MaintNotificationsConfig` for details.
287+ Only supported with RESP3
288+ If not provided and protocol is RESP3, the maintenance notifications
289+ will be enabled by default (logic is included in the connection pool
290+ initialization).
291+ Argument is ignored when connection_pool is provided.
281292 """
282293 if event_dispatcher is None :
283294 self ._event_dispatcher = EventDispatcher ()
@@ -354,6 +365,22 @@ def __init__(
354365 "cache_config" : cache_config ,
355366 }
356367 )
368+ maint_notifications_enabled = (
369+ maint_notifications_config and maint_notifications_config .enabled
370+ )
371+ if maint_notifications_enabled and protocol not in [
372+ 3 ,
373+ "3" ,
374+ ]:
375+ raise RedisError (
376+ "Maintenance notifications handlers on connection are only supported with RESP version 3"
377+ )
378+ if maint_notifications_config :
379+ kwargs .update (
380+ {
381+ "maint_notifications_config" : maint_notifications_config ,
382+ }
383+ )
357384 connection_pool = ConnectionPool (** kwargs )
358385 self ._event_dispatcher .dispatch (
359386 AfterPooledConnectionsInstantiationEvent (
@@ -377,23 +404,6 @@ def __init__(
377404 ]:
378405 raise RedisError ("Client caching is only supported with RESP version 3" )
379406
380- if maint_notifications_config and self .connection_pool .get_protocol () not in [
381- 3 ,
382- "3" ,
383- ]:
384- raise RedisError (
385- "Push handlers on connection are only supported with RESP version 3"
386- )
387- if maint_notifications_config and maint_notifications_config .enabled :
388- self .maint_notifications_pool_handler = MaintNotificationsPoolHandler (
389- self .connection_pool , maint_notifications_config
390- )
391- self .connection_pool .set_maint_notifications_pool_handler (
392- self .maint_notifications_pool_handler
393- )
394- else :
395- self .maint_notifications_pool_handler = None
396-
397407 self .single_connection_lock = threading .RLock ()
398408 self .connection = None
399409 self ._single_connection_client = single_connection_client
@@ -591,15 +601,9 @@ def monitor(self):
591601 return Monitor (self .connection_pool )
592602
593603 def client (self ):
594- maint_notifications_config = (
595- None
596- if self .maint_notifications_pool_handler is None
597- else self .maint_notifications_pool_handler .config
598- )
599604 return self .__class__ (
600605 connection_pool = self .connection_pool ,
601606 single_connection_client = True ,
602- maint_notifications_config = maint_notifications_config ,
603607 )
604608
605609 def __enter__ (self ):
0 commit comments