We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 645fa75 commit 85a924aCopy full SHA for 85a924a
docs/tutorials/task-cookbook.rst
@@ -38,12 +38,12 @@ The cache key expires after some time in case something unexpected happens
38
39
LOCK_EXPIRE = 60 * 5 # Lock expires in 5 minutes
40
41
- @task
42
- def import_feed(feed_url):
+ @task(bind=True)
+ def import_feed(self, feed_url):
43
# The cache key consists of the task name and the MD5 digest
44
# of the feed URL.
45
feed_url_digest = md5(feed_url).hexdigest()
46
- lock_id = '{0}-lock-{1}'.format(__name__, feed_url_hexdigest)
+ lock_id = '{0}-lock-{1}'.format(self.name, feed_url_hexdigest)
47
48
# cache.add fails if the key already exists
49
acquire_lock = lambda: cache.add(lock_id, 'true', LOCK_EXPIRE)
0 commit comments