]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Clear itimer signals in autoreload so the combination of autoreload
authorBen Darnell <bdarnell@beaker.local>
Thu, 22 Apr 2010 23:12:41 +0000 (16:12 -0700)
committerBen Darnell <bdarnell@beaker.local>
Thu, 22 Apr 2010 23:12:41 +0000 (16:12 -0700)
and ioloop.set_blocking_log_threshold doesn't cause the new process
to get killed.

tornado/autoreload.py

index 70ff734205f09762e93202843d0cf84ee1b4f8fe..522d140f2234ddeba024d7cd7c3c822e74363073 100644 (file)
@@ -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: