Skip to content

Commit

Permalink
socketfromfd: remove python 2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Nov 25, 2019
1 parent ceca7c8 commit fa32aa7
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions gunicorn/socketfromfd.py
Expand Up @@ -95,15 +95,8 @@ def fromfd(fd, keep_fd=True):
family = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_DOMAIN)
typ = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_TYPE)
proto = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_PROTOCOL)
if sys.version_info.major == 2:
# Python 2 has no fileno argument and always duplicates the fd
sockobj = socket.fromfd(fd, family, typ, proto)
sock = socket.socket(None, None, None, _sock=sockobj)
if not keep_fd:
os.close(fd)
return sock
s
if keep_fd:
return socket.fromfd(fd, family, typ, proto)
else:
if keep_fd:
return socket.fromfd(fd, family, typ, proto)
else:
return socket.socket(family, typ, proto, fileno=fd)
return socket.socket(family, typ, proto, fileno=fd)

0 comments on commit fa32aa7

Please sign in to comment.