Random Task Name Generator for Celery

  • Share this:

Code introduction


This function generates a random task name, which is used in Celery to create tasks. Task names are typically required to be unique.


Technology Stack : Python standard library (string, random)

Code Type : Function

Code Difficulty : Intermediate


                
                    
def random_task_name_generator():
    import random
    import string
    prefix = "task_"
    return prefix + ''.join(random.choices(string.ascii_letters + string.digits, k=8))