Skip to content

How to load tasks from DB #139

Discussion options

You must be logged in to vote

Hi!

For the first point, Rocketry provides multiple ways to create tasks and those can be tailored as you wish.

One option is to use the app.task which is quite dynamic. The task does not necessarily need to be a decorator:

from rocketry import Rocketry

def get_tasks_from_database():
    # Query your database with whatever way
    ...
    yield {"name": "mytask", "path": "path/to/script.py", "func_name": "main"}

app = Rocketry()

for task_kwargs in get_tasks_from_database():
    app.task(**task_kwargs)

If you wish to have your tasks in sync with the database, you can create a meta task that runs with execution="main" and possibly runs perpetually. This task can poll other tasks from you…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by suresh-subramaniyan-s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants