Python socket OSError: [Errno 101] Network is unreachable,如何在云端启动celery

简介: 报错

当我们把项目部署到云端上,再发送邮件时,我们启动的celery异步任务出错。在Windows上没有错,而在centos上报错。重写了此任务。
解决方案:

def send_verify_email(verify_code,to_email):

smtp = smtplib.SMTP_SSL("smtp.qq.com")

smtp.ehlo("smtp.qq.com")
smtp.login('2259583140@qq.com', 'bjtenrwpbsxgebah')
msg = MIMEMultipart()


subject = Header('BannerStudio旗帜软件工作室', 'utf-8').encode()
msg['Subject'] = subject

msg['From'] = 'qq2259583140'

msg['To'] = to_email
m='您的验证码为%s'%(verify_code)

text = MIMEText(m, 'plain', 'utf-8')
msg.attach(text)

smtp.sendmail('2259583140@qq.com', to_email, msg.as_string())
smtp.quit()

同时,因为我们已经部署在云端上了。因此要用守护进程的方式去开启celery队列,
开启:celery multi start w1 -A celery_test -l info
停止:celery multi stop w1 -A celery_test -l info
重启:celery multi restart w1 -A celery_test -l info

相关文章
|
2月前
|
消息中间件 NoSQL 调度
学Python的别告诉我你还不造celery是干嘛的
​写python的别告诉我你还不造celery干嘛的。Celery是一个简单、灵活且可靠的分布式任务队列系统,用于处理大量消息,提供实时处理,以及异步任务执行。其核心原理包括任务队列、消息传递、任务调度和任务执行。
|
7天前
|
安全 数据安全/隐私保护 开发者
【Python】 已解决:ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: ‘e:\anaconda\i
【Python】 已解决:ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: ‘e:\anaconda\i
21 11
【Python】 已解决:ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: ‘e:\anaconda\i
|
7天前
|
数据处理 开发者 Python
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘E:\自动备份文档\Python\修改配置.csv‘
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘E:\自动备份文档\Python\修改配置.csv‘
15 1
|
1天前
|
网络协议 Python
在Python中,我们使用`socket`模块来进行网络通信。首先,我们需要导入这个模块。
在Python中,我们使用`socket`模块来进行网络通信。首先,我们需要导入这个模块。
4 0
|
6天前
|
UED Python
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘D:\1. PDF’
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘D:\1. PDF’
12 0
|
6天前
|
XML 数据格式 Python
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘./1.xml’
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘./1.xml’
14 0
|
6天前
|
开发者 Python
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘配置信息.csv‘
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘配置信息.csv‘
10 0
|
1月前
|
消息中间件 监控 调度
构建Python中的分布式系统结合Celery与RabbitMQ
在当今的软件开发中,构建高效的分布式系统是至关重要的。Python作为一种流行的编程语言,提供了许多工具和库来帮助开发人员构建分布式系统。其中,Celery和RabbitMQ是两个强大的工具,它们结合在一起可以为你的Python应用程序提供可靠的异步任务队列和消息传递机制。
|
1月前
|
网络协议 Unix API
24.Python 网络编程:socket编程
24.Python 网络编程:socket编程
25 2
|
19天前
|
机器学习/深度学习 网络协议 Python
Python Socket深度学习分享
Python Socket深度学习分享
10 0