run_script_job
Run long Python scripts in a Kit app as jobs and return an ID immediately, enabling work beyond 120-second limits while Kit remains responsive.
Instructions
Start a long Python script inside the Kit app as a job, and answer its id at once: for work that may outlast execute_script's 120 s, such as dropping and settling many objects under physics one after another.
The job runs on Kit's main thread between Kit's updates, so Kit renders and other tools answer while it runs.
It must await once a step: await omni.kit.app.get_app().next_update_async() lets one update pass, physics
stepping while the timeline plays, up to its end: get_sim_state's timeline line says where that is and whether
it loops back there. A script that never awaits at its top level is refused, since its loops
would hold Kit from its start to its end; a coroutine the script only defines or schedules doesn't count: await
it at the top level, await main(). One that awaits once and then loops, or calls Isaac Sim's world.step(),
holds Kit too, and no tool can read or cancel it until it ends. It has execute_script's names (omni, carb, Usd,
UsdGeom, UsdLux, UsdPhysics, Sdf, Gf, mcp); assign to result to return data. Print a line a step: the lines are
the progress get_job shows. Read it with get_job(id, wait=60), cancel it with cancel_job. One job runs at a
time, and the last one is kept until the next starts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Python to run as the job; give this or file | |
| file | No | A .py file on the Kit app's machine to run as the job, read there; or give code |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |