From 41c6125e1b5414b6d784067681739a818e82e579 Mon Sep 17 00:00:00 2001 From: Raphael Deem Date: Sun, 12 Feb 2017 14:40:10 -0800 Subject: [PATCH] use try/except when adding loop sig handlers --- sanic/server.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sanic/server.py b/sanic/server.py index 8b9ed532..8a7969e2 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -346,7 +346,11 @@ def serve(host, port, request_handler, error_handler, before_start=None, # Register signals for graceful termination if register_sys_signals: for _signal in (SIGINT, SIGTERM): - loop.add_signal_handler(_signal, loop.stop) + try: + loop.add_signal_handler(_signal, loop.stop) + except NotImplementedError: + log.warn(('Sanic tried to use loop.add_signal_handler') + ('but it is not implemented on this platform.')) pid = os.getpid() try: