@@ -1379,7 +1379,7 @@ def __init__(
13791379 ssl_cert_reqs: The string value for the SSLContext.verify_mode (none, optional, required), or an ssl.VerifyMode. Defaults to "required".
13801380 ssl_ca_certs: The path to a file of concatenated CA certificates in PEM format. Defaults to None.
13811381 ssl_ca_data: Either an ASCII string of one or more PEM-encoded certificates or a bytes-like object of DER-encoded certificates.
1382- ssl_check_hostname: If set, match the hostname during the SSL handshake. Defaults to False .
1382+ ssl_check_hostname: If set, match the hostname during the SSL handshake. Defaults to True .
13831383 ssl_ca_path: The path to a directory containing several CA certificates in PEM format. Defaults to None.
13841384 ssl_password: Password for unlocking an encrypted private key. Defaults to None.
13851385
@@ -1720,7 +1720,7 @@ def __init__(
17201720 self ._cache_factory = cache_factory
17211721
17221722 if connection_kwargs .get ("cache_config" ) or connection_kwargs .get ("cache" ):
1723- if connection_kwargs .get ("protocol" ) not in [3 , "3" ]:
1723+ if self . connection_kwargs .get ("protocol" ) not in [3 , "3" ]:
17241724 raise RedisError ("Client caching is only supported with RESP version 3" )
17251725
17261726 cache = self .connection_kwargs .get ("cache" )
@@ -1741,31 +1741,21 @@ def __init__(
17411741 connection_kwargs .pop ("cache" , None )
17421742 connection_kwargs .pop ("cache_config" , None )
17431743
1744- if connection_kwargs .get (
1744+ if self . connection_kwargs .get (
17451745 "maintenance_events_pool_handler"
1746- ) or connection_kwargs .get ("maintenance_events_config" ):
1747- if connection_kwargs .get ("protocol" ) not in [3 , "3" ]:
1746+ ) or self . connection_kwargs .get ("maintenance_events_config" ):
1747+ if self . connection_kwargs .get ("protocol" ) not in [3 , "3" ]:
17481748 raise RedisError (
17491749 "Push handlers on connection are only supported with RESP version 3"
17501750 )
1751- config = connection_kwargs .get ("maintenance_events_config" , None ) or (
1752- connection_kwargs .get ("maintenance_events_pool_handler" ).config
1753- if connection_kwargs .get ("maintenance_events_pool_handler" )
1751+ config = self . connection_kwargs .get ("maintenance_events_config" , None ) or (
1752+ self . connection_kwargs .get ("maintenance_events_pool_handler" ).config
1753+ if self . connection_kwargs .get ("maintenance_events_pool_handler" )
17541754 else None
17551755 )
17561756
17571757 if config and config .enabled :
1758- connection_kwargs .update (
1759- {
1760- "orig_host_address" : connection_kwargs .get ("host" ),
1761- "orig_socket_timeout" : connection_kwargs .get (
1762- "socket_timeout" , None
1763- ),
1764- "orig_socket_connect_timeout" : connection_kwargs .get (
1765- "socket_connect_timeout" , None
1766- ),
1767- }
1768- )
1758+ self ._update_connection_kwargs_for_maintenance_events ()
17691759
17701760 self ._event_dispatcher = self .connection_kwargs .get ("event_dispatcher" , None )
17711761 if self ._event_dispatcher is None :
@@ -1821,6 +1811,7 @@ def set_maintenance_events_pool_handler(
18211811 "maintenance_events_config" : maintenance_events_pool_handler .config ,
18221812 }
18231813 )
1814+ self ._update_connection_kwargs_for_maintenance_events ()
18241815
18251816 self ._update_maintenance_events_configs_for_connections (
18261817 maintenance_events_pool_handler
@@ -1838,6 +1829,23 @@ def _update_maintenance_events_configs_for_connections(
18381829 conn .set_maintenance_event_pool_handler (maintenance_events_pool_handler )
18391830 conn .maintenance_events_config = maintenance_events_pool_handler .config
18401831
1832+ def _update_connection_kwargs_for_maintenance_events (self ):
1833+ """Store original connection parameters for maintenance events."""
1834+ if self .connection_kwargs .get ("orig_host_address" , None ) is None :
1835+ # If orig_host_address is None it means we haven't
1836+ # configured the original values yet
1837+ self .connection_kwargs .update (
1838+ {
1839+ "orig_host_address" : self .connection_kwargs .get ("host" ),
1840+ "orig_socket_timeout" : self .connection_kwargs .get (
1841+ "socket_timeout" , None
1842+ ),
1843+ "orig_socket_connect_timeout" : self .connection_kwargs .get (
1844+ "socket_connect_timeout" , None
1845+ ),
1846+ }
1847+ )
1848+
18411849 def reset (self ) -> None :
18421850 self ._created_connections = 0
18431851 self ._available_connections = []
0 commit comments