顾以北

导航

 

2021年6月3日

摘要: 情景: 用户发起request,并等待response返回。在本些views中,可能需要执行一段耗时的程序,那么用户就会等待很长时间,造成不好的用户体验,比如发送邮件、手机验证码等。 使用celery后,情况就不一样了。 解决: 将耗时的程序放到celery中执行。 Celery 是一个包含一系列的 阅读全文
posted @ 2021-06-03 08:59 小高、 阅读(234) 评论(2) 推荐(0) 编辑
 
摘要: 1.With上下文管理器 常用: with open("file_name","wb") as f: f.write("hello flask") 自定义: class Foo(gbiect): def __enter__(self): """进入with语句的时候被with调用""" print( 阅读全文
posted @ 2021-06-03 08:49 小高、 阅读(108) 评论(0) 推荐(0) 编辑