为什么 _thread 在远程服务器上不起作用?

时间:2021-02-26 18:04:49

标签: python django

此代码适用于我的本地服务器,但不适用于主机。可能是什么问题?

import _thread

def email_index(*args):
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.starttls()
    server.login('ki@gmail.com', 'pas')
    try:
        server.sendmail('ki@gmail.com', 'so@gmail.com', body_mes.encode('utf-8'))
        print('ok')
    except:
        print('An error occurred when trying to send an email')
try:
    _thread.start_new_thread( email_index, ("Thread-1", 2, ) )
except:
    print ("Error: unable to start thread")

0 个答案:

没有答案