芹菜工人的运行方式不同吗?

时间:2017-06-02 22:17:06

标签: python celery

我有一段代码在我的python应用程序中正常运行。当芹菜工人运行此代码时,它无法执行此操作。这是代码块:

def send_case_complete_email(owner_name, case_name, email):
    try:
        with open("utility/email/buildCompleteEmail.txt", 'rb') as email_file:
            text = email_file.read().decode("utf-8")
        text = text.replace("<owner>", owner_name).replace("<caseName>", case_name)
        msg = MIMEText(text)
        msg['Subject'] = "Case \'" + case_name + "\' is ready"
        msg['From'] = config_access.app_configs['email']['from']
        msg['To'] = email
        server = smtplib.SMTP(config_access.app_configs['email']['host'])
        if config_access.app_configs['email']['tls']:
            server.starttls()
        server.login(config_access.app_configs['email']['user'], config_access.app_configs['email']['password'])
        server.sendmail(config_access.app_configs['email']['from'], email, msg.as_string())
        print("Case completion email sent to " + email)
    except Exception as e:
        print(e)

来自芹菜工人的错误:

[2017-06-02 15:07:19,031: WARNING/PoolWorker-1] (500, b"5.3.3 Unrecognized command 'bm8ucmVwbHlAcGx1cmlsb2NrLmNvbQ==' [BN3PR03CA0080.namprd03.prod.outlook.com]")

为什么会发生这种情况?

1 个答案:

答案 0 :(得分:0)

您发布的消息只是一条警告消息。你确定这里的错误是来自这段代码。您可以在此处使用日志记录Python Logging

或者如果您正在使用Django,Django Logging 。您可以使用logger.exception来获取完整的堆栈跟踪。这将告诉你错误究竟来自哪里。