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