diff --git a/matemat/webserver/httpd.py b/matemat/webserver/httpd.py index e5d1003..8d72d61 100644 --- a/matemat/webserver/httpd.py +++ b/matemat/webserver/httpd.py @@ -321,9 +321,13 @@ class MatematWebserver(object): def _cron_runner(self, fun: Callable[[Dict[str, str], jinja2.Environment, logging.Logger], None]): self._httpd.logger.info('Executing cron job "%s"', fun.__name__) - fun(self._httpd.pagelet_variables, - self._httpd.jinja_env, - self._httpd.logger) + try: + fun(self._httpd.pagelet_variables, + self._httpd.jinja_env, + self._httpd.logger) + self._httpd.logger.info('Completed cron job "%s"', fun.__name__) + except BaseException as e: + self._httpd.logger.exception('Cron job "%s" failed:', fun.__name__, exc_info=e) class HttpHandler(BaseHTTPRequestHandler):