def insert_into_homefeed(photo_id, user_id, index=0):
    r_server = redis.Redis(connection_pool=pool)
range_limit = index + INSERT_INTO_HOMEFEED_BATCH - 1
followers_list_batch = r_server.lrange('followers:%s' % user_id, index,
    range_limit)
if not followers_list_batch:
    return
for follower_id in followers_list:
    homefeed_list = r_server.lpush('homefeed:%s' % follower_id, photo_id)
insert_into_homefeed.delay(photo_id, user_id, range_limit + 1)
Django, Celery, Redis, RabbitMQ: Chained Tasks for Fanout-On-Writes