From e5535099b1d7cd6e32d3dc74775213501a49c920 Mon Sep 17 00:00:00 2001 From: Albert Armea Date: Wed, 13 May 2015 19:10:20 -0700 Subject: [PATCH] Fix sockutil Windows detection socket.fromfd is only available on Unix, so the check here was erroneously causing an early exit (and not setting socket parameters) on Windows. --- python/skytools/sockutil.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/skytools/sockutil.py b/python/skytools/sockutil.py index 90964f15..816a97ea 100644 --- a/python/skytools/sockutil.py +++ b/python/skytools/sockutil.py @@ -33,16 +33,18 @@ def set_tcp_keepalive(fd, keepalive = True, """ # usable on this OS? - if not hasattr(socket, 'SO_KEEPALIVE') or not hasattr(socket, 'fromfd'): + if not hasattr(socket, 'SO_KEEPALIVE'): return # need socket object if isinstance(fd, socket.SocketType): s = fd - else: + elif hasattr(socket, 'fromfd'): if hasattr(fd, 'fileno'): fd = fd.fileno() s = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) + else: + return # skip if unix socket if type(s.getsockname()) != type(()):