Skip to content

Commit

Permalink
add win32 and fix pytype
Browse files Browse the repository at this point in the history
  • Loading branch information
yocalebo committed Dec 11, 2024
1 parent b59149c commit cca47b7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions truenas_api_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __exit__(self, typ, value, traceback):

def set_socket_options(socobj):
plat = sys.platform
if plat not in ('linux', 'freebsd', 'darwin'):
if plat not in ('win32', 'linux', 'freebsd', 'darwin'):
raise RuntimeError('Unsupported platform')

# enable keepalives on the socket
Expand All @@ -151,10 +151,12 @@ def set_socket_options(socobj):
# 3. for a maximum up to 5 times
#
# after 5 times (5 seconds of no response), the socket will be closed
if plat in ('linux', 'freebsd'):
# pytype: disable=attribute-error
if plat in ('linux', 'freebsd', 'win32'):
socobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 1)
else:
socobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPALIVE, 1)
# pytype: enable=attribute-error

socobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 1)
socobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 5)

0 comments on commit cca47b7

Please sign in to comment.