From 61a8f1e676714cf19bd61c22a16487c124a3b80f Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Sun, 16 Aug 2020 15:34:44 +0200 Subject: [PATCH] ignore the "Popped wrong app context" Assertion Error raised by AppContext --- email_handler.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/email_handler.py b/email_handler.py index 13a7c5d1..afe4abda 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1251,10 +1251,14 @@ class MailHandler: smtp = SMTP(POSTFIX_SERVER, POSTFIX_PORT or 25) app = new_app() - with app.app_context(): - ret = await handle(envelope, smtp) - LOG.debug("takes %s seconds <<===", time.time() - start) - return ret + try: + with app.app_context(): + ret = await handle(envelope, smtp) + LOG.debug("takes %s seconds <<===", time.time() - start) + return ret + # ignore the "Popped wrong app context" Assertion Error raised by AppContext + except AssertionError as e: + LOG.warning("Error %s", e) if __name__ == "__main__":