{"id":742,"date":"2017-01-13T02:41:01","date_gmt":"2017-01-13T02:41:01","guid":{"rendered":"http:\/\/www.selinuxplus.com\/?p=742"},"modified":"2017-01-13T02:41:01","modified_gmt":"2017-01-13T02:41:01","slug":"celery%e7%9a%84options%e4%b8%adexpires","status":"publish","type":"post","link":"http:\/\/www.selinuxplus.com\/?p=742","title":{"rendered":"celery\u7684options\u4e2dexpires"},"content":{"rendered":"<p>CELERYBEAT_SCHEDULE: In each task, you can add an \u2018options\u2019 dictionary and set \u2018expires\u2019 to a number of seconds. If the task doesn\u2019t run within that time, it\u2019ll be discarded rather than run when it finally gets to a worker. This can help a lot with periodic tasks when workers or the queue gets hung up for a while and then unjammed &#8211; without this, the workers will have to work through a huge backlog of the same periodic tasks over and over, for no reason.<\/p>\n<p>Example:<\/p>\n<pre class=\"lang:default decode:true \" >CELERYBEAT_SCHEDULE = {\r\n    'process_new_scans': {\r\n        'task': 'tasks.process_new_scans',\r\n        'schedule': timedelta(minutes=15),\r\n        'options': {\r\n            'expires': 10*60,  # 10 minutes\r\n        }\r\n    },\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CELERYBEAT_SCHEDULE: In e&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[164],"_links":{"self":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/742"}],"collection":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=742"}],"version-history":[{"count":1,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/742\/revisions"}],"predecessor-version":[{"id":743,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/742\/revisions\/743"}],"wp:attachment":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=742"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}