Robert Brewer avatar Robert Brewer committed 5a77592

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

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.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.