From 7f5c7417d82eb11a2ec3240e18a71ee86a45b864 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 22 Jul 2021 16:02:08 -0400 Subject: [PATCH] Print out some additional debugging information in the email script so we can tell what is happening and where. --- crc/__init__.py | 2 +- crc/scripts/email.py | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/crc/__init__.py b/crc/__init__.py index 4552a272..31fb8ceb 100644 --- a/crc/__init__.py +++ b/crc/__init__.py @@ -55,7 +55,7 @@ def process_waiting_tasks(): with app.app_context(): WorkflowService.do_waiting() -scheduler.add_job(process_waiting_tasks,'interval',minutes=5) +scheduler.add_job(process_waiting_tasks,'interval',minutes=1) scheduler.start() diff --git a/crc/scripts/email.py b/crc/scripts/email.py index 83f442db..f98fde2f 100644 --- a/crc/scripts/email.py +++ b/crc/scripts/email.py @@ -1,3 +1,6 @@ +import sys +import traceback + from crc import app from crc.api.common import ApiError from crc.scripts.script import Script @@ -44,16 +47,24 @@ email (subject="My Subject", recipients=["dhf8r@virginia.edu", pi.email], cc='as if recipients: message = task.task_spec.documentation data = task.data - content, content_html = EmailService().get_rendered_content(message, data) - EmailService.add_email( - subject=subject, - sender=app.config['DEFAULT_SENDER'], - recipients=recipients, - content=content, - content_html=content_html, - cc=cc, - study_id=study_id - ) + try: + content, content_html = EmailService().get_rendered_content(message, data) + EmailService.add_email( + subject=subject, + sender=app.config['DEFAULT_SENDER'], + recipients=recipients, + content=content, + content_html=content_html, + cc=cc, + study_id=study_id + ) + except Exception as e: + exc_type, exc_value, exc_traceback = sys.exc_info() + print("*** format_exception:") + # exc_type below is ignored on 3.5 and later + print(repr(traceback.format_exception(exc_type, exc_value, + exc_traceback))) + raise e def get_email_addresses(self, users, study_id): emails = []