(sock: socket.socket, tcp_option: str, max_value: int)
| 103 | else: |
| 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) |
no outgoing calls
no test coverage detected