DBOS Methods & Variables
DBOS provides a number of useful context methods and variables.
All are accessed through the syntax DBOS.<method> and can only be used once a DBOS class object has been initialized.
Context Methods
start_workflow
DBOS.start_workflow(
func: Callable[P, R],
*args: P.args,
**kwargs: P.kwargs,
) -> WorkflowHandle[R]
Start a workflow in the background and return a handle to it.
The DBOS.start_workflow method resolves after the handle is durably created; at this point the workflow is guaranteed to run to completion even if the app is interrupted.
Example syntax:
@DBOS.workflow()
def example_workflow(var1: str, var2: str):
DBOS.logger.info("I am a workflow")
# Start example_workflow in the background
handle: WorkflowHandle = DBOS.start_workflow(example_workflow, "var1", "var2")
start_workflow_async
DBOS.start_workflow_async(
func: Callable[P, Coroutine[Any, Any, R]],
*args: P.args,
**kwargs: P.kwargs,
) -> Coroutine[Any, Any, WorkflowHandleAsync[R]]
Start an asynchronous workflow and return a handle to it.
The DBOS.start_workflow_async method resolves after the handle is durably created; at this point the workflow is guaranteed to run to completion even if the app is interrupted.
The workflow started with DBOS.start_workflow_async runs in the same event loop as its caller.
Example syntax: