use socket.set_inheritable instead of os version

This commit is contained in:
Raphael Deem 2017-04-04 13:13:37 -07:00
parent 2b5e723ea5
commit 1854ad133c

View File

@ -5,13 +5,16 @@ import warnings
from functools import partial from functools import partial
from inspect import isawaitable from inspect import isawaitable
from multiprocessing import Process from multiprocessing import Process
from os import set_inheritable
from signal import ( from signal import (
SIGTERM, SIGINT, SIGTERM, SIGINT,
signal as signal_func, signal as signal_func,
Signals Signals
) )
from socket import socket, SOL_SOCKET, SO_REUSEADDR from socket import (
socket,
SOL_SOCKET,
SO_REUSEADDR,
)
from time import time from time import time
from httptools import HttpRequestParser from httptools import HttpRequestParser
@ -446,7 +449,7 @@ def serve_multiple(server_settings, workers):
sock = socket() sock = socket()
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
sock.bind((server_settings['host'], server_settings['port'])) sock.bind((server_settings['host'], server_settings['port']))
set_inheritable(sock.fileno(), True) sock.set_inheritable(True)
server_settings['sock'] = sock server_settings['sock'] = sock
server_settings['host'] = None server_settings['host'] = None
server_settings['port'] = None server_settings['port'] = None