Skip to content

Run commands in a sandbox

Last updated View as MarkdownAgent setup

Each of the following guides runs a command in a sandbox with exec(). They differ in how the output reaches the caller and in what ends the command:

Guide How the output reaches the caller The command runs until
Run Python code In the response, after the code exits The code exits
Run tests from a Git repository In the response, after the tests finish The tests finish
Stream command output As server-sent events, while the command runs It exits, or the client disconnects
Run background processes In files that later requests read It exits, or a later request stops it
Run a server in the background Over the server port, and in a log file The container stops, or a request stops it
Open a terminal in the browser In an interactive terminal, over a WebSocket You run exit, or your Worker ends the session

For every option that exec() accepts, refer to Execute commands in the Containers documentation.

Was this helpful?