MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _set_tcp_option

Function _set_tcp_option

pymongo/pool_shared.py:105–116  ·  view source on GitHub ↗
(sock: socket.socket, tcp_option: str, max_value: int)

Source from the content-addressed store, hash-verified

103else:
104
105 def _set_tcp_option(sock: socket.socket, tcp_option: str, max_value: int) -> None:
106 if hasattr(socket, tcp_option):
107 sockopt = getattr(socket, tcp_option)
108 try:
109 # PYTHON-1350 - NetBSD doesn't implement getsockopt for
110 # TCP_KEEPIDLE and friends. Don't attempt to set the
111 # values there.
112 default = sock.getsockopt(socket.IPPROTO_TCP, sockopt)
113 if default > max_value:
114 sock.setsockopt(socket.IPPROTO_TCP, sockopt, max_value)
115 except OSError:
116 pass
117
118 def _set_keepalive_times(sock: socket.socket) -> None:
119 _set_tcp_option(sock, "TCP_KEEPIDLE", _MAX_TCP_KEEPIDLE)

Callers 1

_set_keepalive_timesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected