@@ -590,6 +590,12 @@ def default_retry_policy(self, policy):
590590 Setting to zero disables heartbeats.
591591 """
592592
593+ idle_heartbeat_timeout = 30
594+ """
595+ Timeout, in seconds, on which the heartbeat wait for idle connection responses.
596+ Lowering this value can help to discover bad connections earlier.
597+ """
598+
593599 schema_event_refresh_window = 2
594600 """
595601 Window, in seconds, within which a schema component will be refreshed after
@@ -756,7 +762,8 @@ def __init__(self,
756762 reprepare_on_up = True ,
757763 execution_profiles = None ,
758764 allow_beta_protocol_version = False ,
759- timestamp_generator = None ):
765+ timestamp_generator = None ,
766+ idle_heartbeat_timeout = 30 ):
760767 """
761768 ``executor_threads`` defines the number of threads in a pool for handling asynchronous tasks such as
762769 extablishing connection pools or refreshing metadata.
@@ -847,6 +854,7 @@ def __init__(self,
847854 self .max_schema_agreement_wait = max_schema_agreement_wait
848855 self .control_connection_timeout = control_connection_timeout
849856 self .idle_heartbeat_interval = idle_heartbeat_interval
857+ self .idle_heartbeat_timeout = idle_heartbeat_timeout
850858 self .schema_event_refresh_window = schema_event_refresh_window
851859 self .topology_event_refresh_window = topology_event_refresh_window
852860 self .status_event_refresh_window = status_event_refresh_window
@@ -1187,7 +1195,11 @@ def connect(self, keyspace=None, wait_for_all_pools=False):
11871195 self .profile_manager .check_supported () # todo: rename this method
11881196
11891197 if self .idle_heartbeat_interval :
1190- self ._idle_heartbeat = ConnectionHeartbeat (self .idle_heartbeat_interval , self .get_connection_holders )
1198+ self ._idle_heartbeat = ConnectionHeartbeat (
1199+ self .idle_heartbeat_interval ,
1200+ self .get_connection_holders ,
1201+ timeout = self .idle_heartbeat_timeout
1202+ )
11911203 self ._is_setup = True
11921204
11931205 session = self ._new_session (keyspace )
0 commit comments