@@ -1381,7 +1381,7 @@ def __init__(
13811381 ssl_cert_reqs: The string value for the SSLContext.verify_mode (none, optional, required), or an ssl.VerifyMode. Defaults to "required".
13821382 ssl_ca_certs: The path to a file of concatenated CA certificates in PEM format. Defaults to None.
13831383 ssl_ca_data: Either an ASCII string of one or more PEM-encoded certificates or a bytes-like object of DER-encoded certificates.
1384- ssl_check_hostname: If set, match the hostname during the SSL handshake. Defaults to False .
1384+ ssl_check_hostname: If set, match the hostname during the SSL handshake. Defaults to True .
13851385 ssl_ca_path: The path to a directory containing several CA certificates in PEM format. Defaults to None.
13861386 ssl_password: Password for unlocking an encrypted private key. Defaults to None.
13871387
@@ -1722,7 +1722,7 @@ def __init__(
17221722 self ._cache_factory = cache_factory
17231723
17241724 if connection_kwargs .get ("cache_config" ) or connection_kwargs .get ("cache" ):
1725- if connection_kwargs .get ("protocol" ) not in [3 , "3" ]:
1725+ if self . connection_kwargs .get ("protocol" ) not in [3 , "3" ]:
17261726 raise RedisError ("Client caching is only supported with RESP version 3" )
17271727
17281728 cache = self .connection_kwargs .get ("cache" )
@@ -1743,31 +1743,21 @@ def __init__(
17431743 connection_kwargs .pop ("cache" , None )
17441744 connection_kwargs .pop ("cache_config" , None )
17451745
1746- if connection_kwargs .get (
1746+ if self . connection_kwargs .get (
17471747 "maintenance_events_pool_handler"
1748- ) or connection_kwargs .get ("maintenance_events_config" ):
1749- if connection_kwargs .get ("protocol" ) not in [3 , "3" ]:
1748+ ) or self . connection_kwargs .get ("maintenance_events_config" ):
1749+ if self . connection_kwargs .get ("protocol" ) not in [3 , "3" ]:
17501750 raise RedisError (
17511751 "Push handlers on connection are only supported with RESP version 3"
17521752 )
1753- config = connection_kwargs .get ("maintenance_events_config" , None ) or (
1754- connection_kwargs .get ("maintenance_events_pool_handler" ).config
1755- if connection_kwargs .get ("maintenance_events_pool_handler" )
1753+ config = self . connection_kwargs .get ("maintenance_events_config" , None ) or (
1754+ self . connection_kwargs .get ("maintenance_events_pool_handler" ).config
1755+ if self . connection_kwargs .get ("maintenance_events_pool_handler" )
17561756 else None
17571757 )
17581758
17591759 if config and config .enabled :
1760- connection_kwargs .update (
1761- {
1762- "orig_host_address" : connection_kwargs .get ("host" ),
1763- "orig_socket_timeout" : connection_kwargs .get (
1764- "socket_timeout" , None
1765- ),
1766- "orig_socket_connect_timeout" : connection_kwargs .get (
1767- "socket_connect_timeout" , None
1768- ),
1769- }
1770- )
1760+ self ._update_connection_kwargs_for_maintenance_events ()
17711761
17721762 self ._event_dispatcher = self .connection_kwargs .get ("event_dispatcher" , None )
17731763 if self ._event_dispatcher is None :
@@ -1823,6 +1813,7 @@ def set_maintenance_events_pool_handler(
18231813 "maintenance_events_config" : maintenance_events_pool_handler .config ,
18241814 }
18251815 )
1816+ self ._update_connection_kwargs_for_maintenance_events ()
18261817
18271818 self ._update_maintenance_events_configs_for_connections (
18281819 maintenance_events_pool_handler
@@ -1840,6 +1831,23 @@ def _update_maintenance_events_configs_for_connections(
18401831 conn .set_maintenance_event_pool_handler (maintenance_events_pool_handler )
18411832 conn .maintenance_events_config = maintenance_events_pool_handler .config
18421833
1834+ def _update_connection_kwargs_for_maintenance_events (self ):
1835+ """Store original connection parameters for maintenance events."""
1836+ if self .connection_kwargs .get ("orig_host_address" , None ) is None :
1837+ # If orig_host_address is None it means we haven't
1838+ # configured the original values yet
1839+ self .connection_kwargs .update (
1840+ {
1841+ "orig_host_address" : self .connection_kwargs .get ("host" ),
1842+ "orig_socket_timeout" : self .connection_kwargs .get (
1843+ "socket_timeout" , None
1844+ ),
1845+ "orig_socket_connect_timeout" : self .connection_kwargs .get (
1846+ "socket_connect_timeout" , None
1847+ ),
1848+ }
1849+ )
1850+
18431851 def reset (self ) -> None :
18441852 self ._created_connections = 0
18451853 self ._available_connections = []
0 commit comments