Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tasks during runtime #200

Open
carlosealves2 opened this issue Mar 30, 2023 · 1 comment
Open

Add tasks during runtime #200

carlosealves2 opened this issue Mar 30, 2023 · 1 comment

Comments

@carlosealves2
Copy link

Is it possible to add new tasks during the execution period? if yes, could you give me a simple example of how it can be done?

@omu4
Copy link

omu4 commented May 18, 2023

https://rocketry.readthedocs.io/en/stable/cookbook/controlling_runtime.html#manipulating-other-tasks

from rocketry.args import Return, Session
@app.task(after_success(get_task))
def create_task(session=Session(), task_data=Return('get_task')):   
            name = "my_task"
            command = "id"            
            start_cond = "hourly"
            end_cond = running.more_than("2 hours 50 minutes")
            task_execution = "process"
            task_pre_exist = "ignore"
            session.create_task(
                command=command,
                shell=True,
                task_execution=task_execution,
                task_pre_exist=task_pre_exist,  # What happens if a task with given name already exists.
                start_cond=start_cond,
                end_cond=end_cond,
                name=name,
            )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants