Skip to content

Commit 67a5651

Browse files
committed
Add default grpc keepalive value
1 parent 2582597 commit 67a5651

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

ydb/connection.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
YDB_REQUEST_TYPE_HEADER = "x-ydb-request-type"
2727

2828
_DEFAULT_MAX_GRPC_MESSAGE_SIZE = 64 * 10**6
29+
_DEFAULT_KEEPALIVE_TIMEOUT = 10000
2930

3031

3132
def _message_to_string(message):
@@ -185,15 +186,18 @@ def _construct_channel_options(driver_config, endpoint_options=None):
185186
getattr(driver_config, "grpc_lb_policy_name", "round_robin"),
186187
),
187188
]
188-
if driver_config.grpc_keep_alive_timeout is not None:
189-
_default_connect_options.extend(
190-
[
191-
("grpc.keepalive_time_ms", driver_config.grpc_keep_alive_timeout >> 3),
192-
("grpc.keepalive_timeout_ms", driver_config.grpc_keep_alive_timeout),
193-
("grpc.http2.max_pings_without_data", 0),
194-
("grpc.keepalive_permit_without_calls", 0),
195-
]
196-
)
189+
if driver_config.grpc_keep_alive_timeout is None:
190+
driver_config.grpc_keep_alive_timeout = _DEFAULT_KEEPALIVE_TIMEOUT
191+
192+
_default_connect_options.extend(
193+
[
194+
("grpc.keepalive_time_ms", driver_config.grpc_keep_alive_timeout >> 3),
195+
("grpc.keepalive_timeout_ms", driver_config.grpc_keep_alive_timeout),
196+
("grpc.http2.max_pings_without_data", 0),
197+
("grpc.keepalive_permit_without_calls", 0),
198+
]
199+
)
200+
197201
if endpoint_options is not None:
198202
if endpoint_options.ssl_target_name_override:
199203
_default_connect_options.append(

0 commit comments

Comments
 (0)