Skip to content

Commit 85a924a

Browse files
committed
Fix for celery#2120
1 parent 645fa75 commit 85a924a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/tutorials/task-cookbook.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ The cache key expires after some time in case something unexpected happens
3838
3939
LOCK_EXPIRE = 60 * 5 # Lock expires in 5 minutes
4040
41-
@task
42-
def import_feed(feed_url):
41+
@task(bind=True)
42+
def import_feed(self, feed_url):
4343
# The cache key consists of the task name and the MD5 digest
4444
# of the feed URL.
4545
feed_url_digest = md5(feed_url).hexdigest()
46-
lock_id = '{0}-lock-{1}'.format(__name__, feed_url_hexdigest)
46+
lock_id = '{0}-lock-{1}'.format(self.name, feed_url_hexdigest)
4747
4848
# cache.add fails if the key already exists
4949
acquire_lock = lambda: cache.add(lock_id, 'true', LOCK_EXPIRE)

0 commit comments

Comments
 (0)