Browse Source

Merge branch 'apollo13/master'

Ask Solem 15 years ago
parent
commit
9059a43dfa
2 changed files with 8 additions and 6 deletions
  1. 6 5
      docs/cookbook/task-retries.rst
  2. 2 1
      docs/cookbook/tasks.rst

+ 6 - 5
docs/cookbook/task-retries.rst

@@ -8,18 +8,18 @@ Retrying a task if something fails
 
 Simply use :meth:`celery.task.base.Task.retry` to re-sent the task, it will
 do the right thing, and respect the :attr:`celery.task.base.Task.max_retries`
-attribute.
+attribute:
 
 .. code-block:: python
 
     class SendTwitterStatusTask(Task):
     
-        def run(self, oauth, tweet, \*\*kwargs):
+        def run(self, oauth, tweet, **kwargs):
             try:
                 twitter = Twitter(oauth)
                 twitter.update_status(tweet)
             except (Twitter.FailWhaleError, Twitter.LoginError), exc:
-                self.retry(args=[oauth, tweet], kwargs=\*\*kwargs, exc=exc)
+                self.retry(args=[oauth, tweet], exc=exc, **kwargs)
 
 Here we used the ``exc`` argument to pass the current exception to
 :meth:`celery.task.base.Task.retry`. At each step of the retry this exception
@@ -43,11 +43,12 @@ You can also provide the ``countdown`` argument to
     class MyTask(Task):
         default_retry_delay = 30 * 60 # retry in 30 minutes
 
-        def run(self, x, y, \*\*kwargs):
+        def run(self, x, y, **kwargs):
             try:
                 ...
             except Exception, exc:
-                self.retry([x, y], \*\*kwargs, exc=exc,
+                self.retry([x, y], exc=exc,
                            countdown=60 # override the default and
                                         # retry in 1 minute
+                           **kwargs)
 

+ 2 - 1
docs/cookbook/tasks.rst

@@ -56,9 +56,10 @@ The cache key expires after some time in case something unexpected happens
 
             acquire_lock()
             try:
-                feed = Feed.objects.import(feed_url)
+                feed = Feed.objects.import_feed(feed_url)
             finally:
                 release_lock()
 
             return feed.url
+
     tasks.register(FeedImporter)