mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Revert "socketfromfd: remove python 2 compatibility"
This reverts commit 404a7120234e2b1119f4e8a3662c542e4d8700c8.
This commit is contained in:
parent
ab25bae7eb
commit
c58337731a
@ -95,8 +95,15 @@ def fromfd(fd, keep_fd=True):
|
|||||||
family = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_DOMAIN)
|
family = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_DOMAIN)
|
||||||
typ = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_TYPE)
|
typ = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_TYPE)
|
||||||
proto = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_PROTOCOL)
|
proto = _raw_getsockopt(fd, socket.SOL_SOCKET, SO_PROTOCOL)
|
||||||
s
|
if sys.version_info.major == 2:
|
||||||
if keep_fd:
|
# Python 2 has no fileno argument and always duplicates the fd
|
||||||
return socket.fromfd(fd, family, typ, proto)
|
sockobj = socket.fromfd(fd, family, typ, proto)
|
||||||
|
sock = socket.socket(None, None, None, _sock=sockobj)
|
||||||
|
if not keep_fd:
|
||||||
|
os.close(fd)
|
||||||
|
return sock
|
||||||
else:
|
else:
|
||||||
return socket.socket(family, typ, proto, fileno=fd)
|
if keep_fd:
|
||||||
|
return socket.fromfd(fd, family, typ, proto)
|
||||||
|
else:
|
||||||
|
return socket.socket(family, typ, proto, fileno=fd)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user