diff --git a/openedx/core/djangoapps/credit/email_utils.py b/openedx/core/djangoapps/credit/email_utils.py index f837c739e2..ae32e0e9d7 100644 --- a/openedx/core/djangoapps/credit/email_utils.py +++ b/openedx/core/djangoapps/credit/email_utils.py @@ -5,7 +5,6 @@ This file contains utility functions which will responsible for sending emails. import os import logging -import pynliner import urlparse import uuid import HTMLParser @@ -145,6 +144,13 @@ def with_inline_css(html_without_css): with open(css_filepath, "r") as _file: css_content = _file.read() + # pynliner imports cssutils, which has an expensive initialization. All + # told, it can account for 15-20% of "fast" LMS startup (without asset + # compilation). So we're going to load it locally here so that we delay + # that one-time hit until we actually do the (rare) operation that is + # sending a credit notification email. + import pynliner + # insert style tag in the html and run pyliner. html_with_inline_css = pynliner.fromString('' + html_without_css) return html_with_inline_css