{"id":101020,"date":"2020-05-21T13:32:35","date_gmt":"2020-05-21T05:32:35","guid":{"rendered":"http:\/\/4563.org\/?p=101020"},"modified":"2020-05-21T13:32:35","modified_gmt":"2020-05-21T05:32:35","slug":"%e5%8e%bb%e5%b9%b4%e5%86%99%e7%9a%84%e4%b8%80%e4%b8%aa%e5%b0%8f-library-django-3-%e4%b8%8d%e9%9c%80%e8%a6%81%e9%a2%9d%e5%a4%96-worker-%e7%9a%84%e5%90%8e%e5%8f%b0%e4%bb%bb%e5%8a%a1","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=101020","title":{"rendered":"\u53bb\u5e74\u5199\u7684\u4e00\u4e2a\u5c0f library \u2014\u2014 Django 3 \u4e0d\u9700\u8981\u989d\u5916 worker \u7684\u540e\u53f0\u4efb\u52a1\u5904\u7406"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u53bb\u5e74\u5199\u7684\u4e00\u4e2a\u5c0f library \u2014\u2014 Django 3 \u4e0d\u9700\u8981\u989d\u5916 worker \u7684\u540e\u53f0\u4efb\u52a1\u5904\u7406               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ericls <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u7b80\u5355\u7528\u4f8b\uff1a<\/p>\n<pre><code>from django_simple_task import defer  def task1():     time.sleep(1)     print(\"task1 done\")  async def task2():     await asyncio.sleep(1)     print(\"task2 done\")  def view(requests):     defer(task1)     defer(task2)     return HttpResponse(b\"My View\") <\/code><\/pre>\n<p>\u8fd9\u91cc task1 \u548c task2 \u90fd\u4f1a\u5728 view \u8fd4\u56de\u540e\u6267\u884c\u3002<\/p>\n<p>\u8fd9\u4e2a\u4e1c\u897f\u4e0d\u80fd\u66ff\u4ee3 celery\uff0c\u53ea\u9002\u5408\u4e00\u4e9b\u7b80\u77ed\u4e14\u4e0d critical \u7684\u4efb\u52a1\u3002\u867d\u6709\u6709\u4e00\u4e9b\u673a\u5236\u63a7\u5236\u5e76\u53d1\u6570\u91cf\u548c\u7ed3\u675f\u5e94\u7528\u524d\u7b49\u5f85\u961f\u5217\u6e05\u7a7a\u3002<\/p>\n<p>\u8fd9\u4e2a\u539f\u7406\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u5982\u679c\u6bcf\u4e2a\u9879\u76ee\u90fd\u81ea\u5df1\u5199\u4e00\u4e2a\u53c8\u5f88\u9ebb\u70e6 \u6240\u4ee5\u5c31\u6574\u7406\u4e86\u4e00\u4e0b\u3002 \u6709\u5174\u8da3\u7684\u8bf7\u70b9\u4e0b\u9762\u7684\u94fe\u63a5\uff1a<\/p>\n<p>View on PyPI<\/p>\n<p>View on GitHub<\/p>\n<p>Read the docs<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1670385\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hjahgdthab750 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             django-q \u9664\u4e86\u5f3a\u5236\u65f6\u533a\u7684\u95ee\u9898\u4ee5\u5916\uff0c\u633a\u597d\u7528\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1670386\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : ericls <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @hjahgdthab750 \u662f\u7684 django-q \u7528\u8fc7\u4e24\u6b21 \u89c9\u5f97\u53ef\u4ee5\u4ee3\u66ff celery \u3002 \u4f46\u662f Celery \u6bd5\u7adf\u8fd8\u662f\u6700\u719f\u6089                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1670387\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hjahgdthab750 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ericls celery \u5b9e\u5728\u662f\u592a\u91cd\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1670388\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : ericls <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @hjahgdthab750 \u9879\u76ee\u66f4\u91cd\u7684\u65f6\u5019 celery \u5c31\u663e\u5f97\u5f88\u8f7b\u4e86 \u54c8\u54c8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u53bb\u5e74\u5199\u7684\u4e00\u4e2a\u5c0f library \u2014&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/101020"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=101020"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/101020\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=101020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=101020"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=101020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}