Merge pull request #506 from zenixls2/bugfix/bind-listener
special handling when sock is provided and number of workers > 1
This commit is contained in:
commit
5aed18862d
|
@ -396,13 +396,15 @@ def serve_multiple(server_settings, workers, stop_event=None):
|
||||||
" has more information.", DeprecationWarning)
|
" has more information.", DeprecationWarning)
|
||||||
server_settings['reuse_port'] = True
|
server_settings['reuse_port'] = True
|
||||||
|
|
||||||
sock = socket()
|
# Handling when custom socket is not provided.
|
||||||
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
|
if server_settings.get('sock') is None:
|
||||||
sock.bind((server_settings['host'], server_settings['port']))
|
sock = socket()
|
||||||
set_inheritable(sock.fileno(), True)
|
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
|
||||||
server_settings['sock'] = sock
|
sock.bind((server_settings['host'], server_settings['port']))
|
||||||
server_settings['host'] = None
|
set_inheritable(sock.fileno(), True)
|
||||||
server_settings['port'] = None
|
server_settings['sock'] = sock
|
||||||
|
server_settings['host'] = None
|
||||||
|
server_settings['port'] = None
|
||||||
|
|
||||||
if stop_event is None:
|
if stop_event is None:
|
||||||
stop_event = Event()
|
stop_event = Event()
|
||||||
|
@ -423,6 +425,6 @@ def serve_multiple(server_settings, workers, stop_event=None):
|
||||||
# the above processes will block this until they're stopped
|
# the above processes will block this until they're stopped
|
||||||
for process in processes:
|
for process in processes:
|
||||||
process.terminate()
|
process.terminate()
|
||||||
sock.close()
|
server_settings.get('sock').close()
|
||||||
|
|
||||||
asyncio.get_event_loop().stop()
|
asyncio.get_event_loop().stop()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user