1. garyvdm
  2. PasteScript

Commits

garyvdm  committed a5049b0

If running serve with --reload, continue to reload if a SyntaxError is encontered on load.

  • Participants
  • Parent commits e701753
  • Branches default

Comments (0)

Files changed (1)

File paste/script/serve.py

View file
  • Ignore whitespace
 import errno
 import sys
 import time
+import traceback
 try:
     import subprocess
 except ImportError:
 import logging
 import ConfigParser
 
+
 MAXFD = 1024
 
 jython = sys.platform.startswith('java')
             log_fn = os.path.join(base, log_fn)
             self.logging_file_config(log_fn)
 
-        server = self.loadserver(server_spec, name=server_name,
-                                 relative_to=base, global_conf=vars)
-        app = self.loadapp(app_spec, name=app_name,
-                           relative_to=base, global_conf=vars)
+        try:
+            server = self.loadserver(server_spec, name=server_name,
+                                     relative_to=base, global_conf=vars)
+            app = self.loadapp(app_spec, name=app_name,
+                               relative_to=base, global_conf=vars)
+        except SyntaxError, e:
+            if self.options.reload and os.environ.get(self._reloader_environ_key):
+                traceback.print_exc()
+                reloader.watch_file(e.filename)
+                while True:
+                    time.sleep(60*60)
+            else:
+                raise
 
         if self.verbose > 0:
             if hasattr(os, 'getpid'):
                         os.kill(proc.pid, signal.SIGTERM)
                     except (OSError, IOError):
                         pass
-
+            print exit_code
             if reloader:
                 # Reloader always exits with code 3; but if we are
                 # a monitor, any exit code will restart