Asynchronous Execution

Workflows have the ability to execute tasks concurrently using the run_async field. This is ideal for tasks that are independent or rely on external systems (e.g., APIs, background jobs).

Why Use run_async?

  • To avoid blocking the pipeline while waiting on long-running tasks
  • To run multiple tasks in parallel for performance
  • To perform background actions (e.g., notifications, processing jobs)

Where run_async Can Be Used

You can use run_async on:

  • ChipTask
  • CodeTask
  • DispatchTask
  • TaskSet

How It Works

When a task runs asynchronously, the result is not immediately usable - it is a task handle. You must store it using store_result_as or append_result_into and wait for it later.

Example: Async + Await


- name: "Start background report"
  run_async: true
  chip: reports.generate
  params:
    user_id: user.id
  store_result_as: background_task

- name: "Wait for report"
  chip: reasonchip.async.wait_for
  params:
    task: background_task
  store_result_as: final_report
	

In this example:

  • background_task holds the async task reference
  • reasonchip.async.wait_for waits for it to finish
  • The final result is stored in final_report

Best Practices & Considerations

  • Always use store_result_as with run_async
  • To get the actual result, you must await the task for completion.
  • Do not use the task handle directly - it is not the final result
  • Ensure the task’s result is not needed immediately if run asynchronously
  • Avoid using async with tasks that modify shared data unless properly synchronized

© 2025 South Patron LLC. All rights reserved.

AI everywhere.