{"id":6135,"date":"2022-04-05T18:34:50","date_gmt":"2022-04-05T10:34:50","guid":{"rendered":"https:\/\/egonlin.com\/?p=6135"},"modified":"2022-04-26T13:50:18","modified_gmt":"2022-04-26T05:50:18","slug":"%e7%ac%ac%e5%8d%81%e5%85%ad%e8%8a%82%ef%bc%9acelery","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=6135","title":{"rendered":"\u7b2c\u5341\u516d\u8282\uff1aCelery"},"content":{"rendered":"<h1>Celery<\/h1>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/Celery1.jpg'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/Celery1.jpg\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<h2>\u4e00\u3001\u4ec0\u4e48\u662fCelery\uff1f<\/h2>\n<blockquote>\n<p>Celery\u662f\u4e00\u4e2a\u7b80\u5355\u3001\u7075\u6d3b\u4e14\u53ef\u9760\u7684\uff0c\u5904\u7406\u5927\u91cf\u6d88\u606f\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf<\/p>\n<p>\u4e13\u6ce8\u4e8e\u5b9e\u65f6\u5904\u7406\u7684\u5f02\u6b65\u4efb\u52a1\u961f\u5217<\/p>\n<p>\u540c\u65f6\u4e5f\u652f\u6301\u4efb\u52a1\u8c03\u5ea6<\/p>\n<\/blockquote>\n<h2>\u4e8c\u3001Celery\u67b6\u6784<\/h2>\n<blockquote>\n<p>Celery\u7684\u67b6\u6784\u7531\u4e09\u90e8\u5206\u7ec4\u6210\uff0c\u6d88\u606f\u4e2d\u95f4\u4ef6\uff08message broker\uff09\uff0c\u4efb\u52a1\u6267\u884c\u5355\u5143\uff08worker\uff09\u548c\u4efb\u52a1\u6267\u884c\u7ed3\u679c\u5b58\u50a8\uff08task result store\uff09\u7ec4\u6210\u3002<\/p>\n<\/blockquote>\n<h3>1\u3001\u6d88\u606f\u4e2d\u95f4\u4ef6<\/h3>\n<blockquote>\n<p>Celery\u672c\u8eab\u4e0d\u63d0\u4f9b\u6d88\u606f\u670d\u52a1\uff0c\u4f46\u662f\u53ef\u4ee5\u65b9\u4fbf\u7684\u548c\u7b2c\u4e09\u65b9\u63d0\u4f9b\u7684\u6d88\u606f\u4e2d\u95f4\u4ef6\u96c6\u6210\u3002\u5305\u62ec\uff0cRabbitMQ, Redis\u7b49\u7b49<\/p>\n<\/blockquote>\n<h3>2\u3001\u4efb\u52a1\u6267\u884c\u5355\u5143<\/h3>\n<blockquote>\n<p>Worker\u662fCelery\u63d0\u4f9b\u7684\u4efb\u52a1\u6267\u884c\u7684\u5355\u5143\uff0cworker\u5e76\u53d1\u7684\u8fd0\u884c\u5728\u5206\u5e03\u5f0f\u7684\u7cfb\u7edf\u8282\u70b9\u4e2d\u3002<\/p>\n<\/blockquote>\n<h3>3\u3001\u4efb\u52a1\u7ed3\u679c\u5b58\u50a8<\/h3>\n<blockquote>\n<p>Task result store\u7528\u6765\u5b58\u50a8Worker\u6267\u884c\u7684\u4efb\u52a1\u7684\u7ed3\u679c\uff0cCelery\u652f\u6301\u4ee5\u4e0d\u540c\u65b9\u5f0f\u5b58\u50a8\u4efb\u52a1\u7684\u7ed3\u679c\uff0c\u5305\u62ecAMQP, redis\u7b49<\/p>\n<\/blockquote>\n<h2>\u4e09\u3001\u7248\u672c\u652f\u6301\u60c5\u51b5<\/h2>\n<pre><code class=\"language-bash\">Celery version 4.0 runs on\n        Python \u27682.7, 3.4, 3.5\u2769\n        PyPy \u27685.4, 5.5\u2769\n    This is the last version to support Python 2.7, and from the next version (Celery 5.x) Python 3.5 or newer is required.\n    If you\u2019re running an older version of Python, you need to be running an older version of Celery:\n        Python 2.6: Celery series 3.1 or earlier.\n        Python 2.5: Celery series 3.0 or earlier.\n        Python 2.4 was Celery series 2.2 or earlier.\nCelery is a project with minimal funding, so we don\u2019t support Microsoft Windows. Please don\u2019t open any issues related to that platform.<\/code><\/pre>\n<h2>\u56db\u3001\u4f7f\u7528\u573a\u666f<\/h2>\n<blockquote>\n<p>\u5f02\u6b65\u4efb\u52a1\uff1a\u5c06\u8017\u65f6\u64cd\u4f5c\u4efb\u52a1\u63d0\u4ea4\u7ed9Celery\u53bb\u5f02\u6b65\u6267\u884c\uff0c\u6bd4\u5982\u53d1\u9001\u77ed\u4fe1\/\u90ae\u4ef6\u3001\u6d88\u606f\u63a8\u9001\u3001\u97f3\u89c6\u9891\u5904\u7406\u7b49\u7b49<\/p>\n<p>\u5b9a\u65f6\u4efb\u52a1\uff1a\u5b9a\u65f6\u6267\u884c\u67d0\u4ef6\u4e8b\u60c5\uff0c\u6bd4\u5982\u6bcf\u5929\u6570\u636e\u7edf\u8ba1<\/p>\n<\/blockquote>\n<h2>\u4e94\u3001Celery\u7684\u5b89\u88c5\u914d\u7f6e<\/h2>\n<pre><code class=\"language-python\">pip install celery\n\u6d88\u606f\u4e2d\u95f4\u4ef6\uff1aRabbitMQ\/Redis\napp=Celery(&#039;\u4efb\u52a1\u540d&#039;\uff0cbackend=&#039;xxx&#039;,broker=&#039;xxx&#039;)<\/code><\/pre>\n<h2>\u516d\u3001Celery\u6267\u884c\u5f02\u6b65\u4efb\u52a1<\/h2>\n<p><\/p><div id=\"rml_readmorelogin_placeholder\" style=\"position:relative;\"><div id=\"rml_fade_content\" style=\"position: absolute;\r\ntop:-10em;\r\nwidth:100%;\r\nheight:10em;\r\nbackground: -webkit-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -moz-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -o-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -ms-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\"><\/div><div class=\"wpf-controller aru_rml_from_in_post\" style=\"background-color:#eeeeee;border:5px solid #cce6ff;\" id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><h2 id=\"Header\">\u67e5\u770b\u66f4\u591a<\/h2><div id=\"Message\"><p>\u8054\u7cfb\u7ba1\u7406\u5458\u5fae\u4fe1tutu19192010\uff0c\u6ce8\u518c\u8d26\u53f7<\/p>\n<\/div><div id=\"StatusBarHeader\"><\/div><form id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><input name=\"post_id\" value=\"6135\" type=\"hidden\"\/><input name=\"_init_callback\" value=\"InitLogin\" type=\"hidden\"\/><input name=\"post_id\" value=\"6135\" type=\"hidden\"\/><input name=\"rt_ype\" value=\"1\" type=\"hidden\"\/><input name=\"nonce\" value=\"6f4377c83f\" type=\"hidden\"\/><input name=\"_wpnonce\" value=\"94db081d56\" type=\"hidden\"\/><input name=\"_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_proxy_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_view\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginView\" type=\"hidden\"\/><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\" width=\"400px\"><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Username:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"username\" value=\"\" type=\"text\"\/><\/td><\/tr><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Password:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"password\" value=\"\" type=\"password\"\/><\/td><\/tr><\/tbody><\/table><p class=\"wpf-table-placeholder submit\"><button class=\"wp_plugin_framework_ajax_button\" type=\"button\" style=\"background-color:#4D90FE;;color:#ffffff;;border:1px solid #3079ed;\" name=\"_event\" value=\"ButtonLogin\">Log in<\/button><\/p><\/td><td class=\"wpf-table-placeholder-input\"><\/td><\/tr><\/tbody><\/table><\/form><div id=\"ButtonStartRegister\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=register\">Register<\/a><\/div><div id=\"Link1\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=lostpassword\">Forgotten username or password?<\/a><\/div><div id=\"StatusBarFooter\"><\/div><\/div><\/div><div id=aru_remaining_content><\/div>","protected":false},"excerpt":{"rendered":"<p>Celery \u4e00\u3001\u4ec0\u4e48\u662fCelery\uff1f Celery\u662f\u4e00\u4e2a\u7b80\u5355\u3001\u7075\u6d3b\u4e14\u53ef\u9760\u7684\uff0c\u5904\u7406\u5927\u91cf\u6d88\u606f\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf \u4e13\u6ce8\u4e8e [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":6782,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,405],"tags":[],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/6135"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6135"}],"version-history":[{"count":0,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/6135\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/media\/6782"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}