File tree Expand file tree Collapse file tree
conjure_python_client/_http Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626import random
2727import requests
2828import socket
29- import sys
3029
3130
3231T = TypeVar ("T" )
5554 socket .SO_KEEPALIVE ,
5655 1 ,
5756) # Enable keep alive.
58- SOCKET_KEEP_INTVL = (
59- socket .SOL_TCP ,
60- socket .TCP_KEEPINTVL ,
61- 120 ,
62- ) # Interval of 120s between individual keepalive probes.
63- KEEP_ALIVE_SOCKET_OPTIONS = [SOCKET_KEEP_ALIVE , SOCKET_KEEP_INTVL ]
64- if sys .platform != "darwin" :
57+ KEEP_ALIVE_SOCKET_OPTIONS = [SOCKET_KEEP_ALIVE ]
58+ if hasattr (socket , "TCP_KEEPINTVL" ):
59+ SOCKET_KEEP_INTVL = (
60+ socket .SOL_TCP ,
61+ socket .TCP_KEEPINTVL ,
62+ 120 ,
63+ ) # Interval of 120s between individual keepalive probes.
64+ KEEP_ALIVE_SOCKET_OPTIONS .append (SOCKET_KEEP_INTVL )
65+ if hasattr (socket , "TCP_KEEPIDLE" ):
6566 SOCKET_KEEP_IDLE = (
6667 socket .SOL_TCP ,
6768 socket .TCP_KEEPIDLE ,
Original file line number Diff line number Diff line change 11import copy
22import pickle
3- import sys
3+ import socket
44
55from conjure_python_client ._http .requests_client import (
66 ConjureHTTPError ,
77 SOCKET_KEEP_ALIVE ,
8- SOCKET_KEEP_INTVL ,
98 TransportAdapter ,
109)
1110from requests .exceptions import HTTPError
1211
13- if sys .platform != "darwin" :
12+ if hasattr (socket , "TCP_KEEPINTVL" ):
13+ from conjure_python_client ._http .requests_client import SOCKET_KEEP_INTVL
14+ if hasattr (socket , "TCP_KEEPIDLE" ):
1415 from conjure_python_client ._http .requests_client import SOCKET_KEEP_IDLE
1516
1617
@@ -28,8 +29,9 @@ def test_keep_alive_passes_correct_options():
2829 max_retries = 12 , enable_keep_alive = True
2930 ).poolmanager .connection_pool_kw ["socket_options" ]
3031 assert SOCKET_KEEP_ALIVE in socket_options
31- assert SOCKET_KEEP_INTVL in socket_options
32- if sys .platform != "darwin" :
32+ if hasattr (socket , "TCP_KEEPINTVL" ):
33+ assert SOCKET_KEEP_INTVL in socket_options
34+ if hasattr (socket , "TCP_KEEPIDLE" ):
3335 assert SOCKET_KEEP_IDLE in socket_options
3436
3537
You can’t perform that action at this time.
0 commit comments