From ad1c1e75753104d933764e98e9302ae14669db12 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 25 May 2017 08:00:27 +0530 Subject: [PATCH] Report a failure to compile as a start failure --- src/calibre/srv/embedded.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/calibre/srv/embedded.py b/src/calibre/srv/embedded.py index 2f3bfc9333..ab5fb7b976 100644 --- a/src/calibre/srv/embedded.py +++ b/src/calibre/srv/embedded.py @@ -80,6 +80,18 @@ class Server(object): def serve_forever(self): self.exception = None from calibre.srv.content import reset_caches + try: + _df = os.environ.get('CALIBRE_DEVELOP_FROM', None) + if _df and os.path.exists(_df): + from calibre.utils.rapydscript import compile_srv + compile_srv() + except BaseException as e: + if self.start_failure_callback is not None: + try: + self.start_failure_callback(as_unicode(e)) + except Exception: + pass + return if self.state_callback is not None: try: self.state_callback(True) @@ -87,10 +99,6 @@ class Server(object): pass reset_caches() # we reset the cache as the server tdir has changed try: - _df = os.environ.get('CALIBRE_DEVELOP_FROM', None) - if _df and os.path.exists(_df): - from calibre.utils.rapydscript import compile_srv - compile_srv() self.loop.serve_forever() except BaseException as e: self.exception = e