Skip to content

nvmalovichko/celery-redis-one-task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

celery-redis-one-task: celery redis one instance task

This module provides utils for creating one instance tasks with celery (using Redis).

Examples

  • Simple one instance task.

    (60*15 - redis cached lock id maximum lifetime in seconds. When task is ended, lock will be deleted automatically.)

@shared_task(name='Task name')
@singleton_task(60 * 15)
def mytask():
    print('task execution')
  • Parameterized one instance task. Look at kwargs={'add_spices': number).

    (60*15 - redis cached lock id maximum lifetime in seconds. When task is ended, lock will be deleted automatically.)

@shared_task(name='Task name')
@singleton_task(60 * 15)
def decorated_function_main():
    for number in range(25):
        arg1 = number ** 2
        arg2 = number * 3 - 1
        app.send_task('Subtask name',
                      args=[arg1, arg2],
                      kwargs={'add_spices': number},
                      countdown=10,
                      expires=180,
                      queue='priority_mid')
                      
@shared_task(name='Subtask name')
@spiced_singleton_task(60 * 15)
def mytask():
    print('subtask execution')

About

Make your celery task instances single

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages