worker process should ignore SIGINT when run_multiple
This commit is contained in:
parent
11017902be
commit
6a61fce84e
|
@ -5,7 +5,7 @@ from functools import partial
|
||||||
from inspect import isawaitable
|
from inspect import isawaitable
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
from signal import (
|
from signal import (
|
||||||
SIGTERM, SIGINT,
|
SIGTERM, SIGINT, SIG_IGN,
|
||||||
signal as signal_func,
|
signal as signal_func,
|
||||||
Signals
|
Signals
|
||||||
)
|
)
|
||||||
|
@ -607,6 +607,10 @@ def serve(host, port, request_handler, error_handler, before_start=None,
|
||||||
|
|
||||||
trigger_events(after_start, loop)
|
trigger_events(after_start, loop)
|
||||||
|
|
||||||
|
# Ignore SIGINT when run_multiple
|
||||||
|
if run_multiple:
|
||||||
|
signal_func(SIGINT, SIG_IGN)
|
||||||
|
|
||||||
# Register signals for graceful termination
|
# Register signals for graceful termination
|
||||||
if register_sys_signals:
|
if register_sys_signals:
|
||||||
_singals = (SIGTERM,) if run_multiple else (SIGINT, SIGTERM)
|
_singals = (SIGTERM,) if run_multiple else (SIGINT, SIGTERM)
|
||||||
|
@ -694,6 +698,7 @@ def serve_multiple(server_settings, workers):
|
||||||
signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
|
signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
|
||||||
|
|
||||||
processes = []
|
processes = []
|
||||||
|
|
||||||
for _ in range(workers):
|
for _ in range(workers):
|
||||||
process = Process(target=serve, kwargs=server_settings)
|
process = Process(target=serve, kwargs=server_settings)
|
||||||
process.daemon = True
|
process.daemon = True
|
||||||
|
|
Loading…
Reference in New Issue
Block a user