Commits

Robert Brewer committed 5a77592

autoreload now calls server.stop() on interrupt. No test for it though. :(

  • Participants
  • Parent commits 27e9c4b

Comments (0)

Files changed (2)

cherrypy/_cpserver.py

                     autoreload.main(self._start)
                 except KeyboardInterrupt:
                     cherrypy.log("<Ctrl-C> hit: shutting down autoreloader", "HTTP")
+                    self.stop()
+                except SystemExit:
+                    cherrypy.log("SystemExit raised: shutting down autoreloader", "HTTP")
+                    self.stop()
                 return
         
         self._start()

cherrypy/lib/autoreload.py

             args = ['"%s"' % arg for arg in args]
         new_environ = os.environ.copy()
         new_environ["RUN_MAIN"] = 'true'
-        exit_code = os.spawnve(os.P_WAIT, sys.executable,
-                               args, new_environ)
+        exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
         if exit_code != 3:
             return exit_code
 
             kwargs = {}
         thread.start_new_thread(main_func, args, kwargs)
         
-        try:
-            reloader_thread()
-        except KeyboardInterrupt:
-            pass
+        # If KeyboardInterrupt is raised within reloader_thread,
+        # let it propagate out to the caller.
+        reloader_thread()
     else:
         # If KeyboardInterrupt is raised within restart_with_reloader,
         # let it propagate out to the caller.