Merge pull request #1565 from ketan86/1564-processes-initialization-fix

1564 - Moving `processes` variable intialization before `sig_handler`.
This commit is contained in:
7 2019-05-09 04:13:29 +08:00 committed by GitHub
commit f70ab2f68a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -842,6 +842,8 @@ def serve_multiple(server_settings, workers):
server_settings["host"] = None server_settings["host"] = None
server_settings["port"] = None server_settings["port"] = None
processes = []
def sig_handler(signal, frame): def sig_handler(signal, frame):
logger.info("Received signal %s. Shutting down.", Signals(signal).name) logger.info("Received signal %s. Shutting down.", Signals(signal).name)
for process in processes: for process in processes:
@ -850,8 +852,6 @@ def serve_multiple(server_settings, workers):
signal_func(SIGINT, lambda s, f: sig_handler(s, f)) signal_func(SIGINT, lambda s, f: sig_handler(s, f))
signal_func(SIGTERM, lambda s, f: sig_handler(s, f)) signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
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