Search code examples
pythonmongodbcelerycelerybeat

get all the values of particular key using PeriodicTask of celerybeatmongo.models


I am using PeriodicTask of celerybeatmongo.models to schedule my tasks. I have a requirement where I need to fetch all the values of particular key. Something like this - Get all the values of a particular key, but using celerybeatmongo.


Solution

  • After lot many trail and error found the solution. The below is the small piece of code that does the required task:

        connect(host=mongo_uri)
        tasks_list = []
        for doc in PeriodicTask.objects():
            if doc.enabled:
                tasks_list.append(doc.name)
        disconnect()