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