From 0fcef4e2376626a2d961931243ab0a828be956d2 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Thu, 22 Apr 2010 16:12:41 -0700 Subject: [PATCH] Clear itimer signals in autoreload so the combination of autoreload and ioloop.set_blocking_log_threshold doesn't cause the new process to get killed. --- tornado/autoreload.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tornado/autoreload.py b/tornado/autoreload.py index 70ff7342..522d140f 100644 --- a/tornado/autoreload.py +++ b/tornado/autoreload.py @@ -29,6 +29,11 @@ import os.path import sys import types +try: + import signal +except ImportError: + signal = None + def start(io_loop=None, check_time=500): """Restarts the process automatically when a module is modified. @@ -74,6 +79,11 @@ def _reload_on_update(io_loop, modify_times): os.close(fd) except: pass + if hasattr(signal, "setitimer"): + # Clear the alarm signal set by + # ioloop.set_blocking_log_threshold so it doesn't fire + # after the exec. + signal.setitimer(signal.ITIMER_REAL, 0, 0) try: os.execv(sys.executable, [sys.executable] + sys.argv) except OSError, e: