{"id":7797,"date":"2015-10-27T08:59:17","date_gmt":"2015-10-27T08:59:17","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/10\/27\/retrying-tasks-with-django-celery-django-celery-open-source-projects-celery-celery\/"},"modified":"2015-10-27T08:59:17","modified_gmt":"2015-10-27T08:59:17","slug":"retrying-tasks-with-django-celery-django-celery-open-source-projects-celery-celery","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/10\/27\/retrying-tasks-with-django-celery-django-celery-open-source-projects-celery-celery\/","title":{"rendered":"Retrying tasks with Django-Celery &#8211; Django\/Celery-open source projects celery\/celery"},"content":{"rendered":"<p>I&#8217;m having problems retrying tasks, here is what a test task looks like<\/p>\n<pre><code>from celery.decorators import task\n\n@task()\ndef add(x, y):\n    if not x or not y:\n        raise Exception(\"test error\")\n    return x+y\n<\/code><\/pre>\n<p>I cannot find any documentation what-so-ever on how to retry decoarted tasks, all I found was this:<\/p>\n<pre><code>self.retry(x,y, exc=exception, countdown=30)\n<\/code><\/pre>\n<p>which doesn&#8217;t seem to work with my case as there is not <code>self<\/code> variable being passed from the method.<\/p>\n<h2>Edit:<\/h2>\n<p>I&#8217;m trying the following now to no avail:<\/p>\n<pre><code>from celery.decorators import task\n\n@task()\ndef add(x, y):\n    if not x or not y:\n        try:\n            raise Exception(\"test error\")\n        except Exception, e:\n            add.retry([x, y], exc=e, countdown=30)\n    return x+y\n<\/code><\/pre>\n<p>I get the following error:<\/p>\n<blockquote>\n<p>TypeError(&#8220;kwargs argument to retries can&#8217;t be empty. Task must accept **kwargs, see http:\/\/bit.ly\/cAx3Bg&#8221;,)<\/p>\n<\/blockquote>\n<p>Any ideas?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m having problems retrying tasks, here is what a test task looks like from celery.decorators import task @task() def add(x, y): if not x or not y: raise Exception(&#8220;test error&#8221;) return x+y I cannot find any documentation what-so-ever on how to retry decoarted tasks, all I found was this: self.retry(x,y, exc=exception, countdown=30) which doesn&#8217;t seem [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7797","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7797"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7797\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}