Overview
Process management is essential for:- Monitoring background execution progress
- Checking process status and output
- Terminating long-running or stuck processes
- Managing multiple concurrent executions
Process management works with processes started via
run_code_background(). For system processes, see system process listing in the Observability section.Listing Processes
List all background execution processes:- Python
- JavaScript
Process Status
Check detailed status of processes:- Python
- JavaScript
Process States
Processes can be in different states:queued- Waiting to startrunning- Currently executingcompleted- Finished successfullyfailed- Execution failedkilled- Terminated by user
- Python
- JavaScript
Killing Processes
Terminate running processes:- Python
- JavaScript
Monitoring Multiple Processes
Monitor multiple processes simultaneously:- Python
- JavaScript
Complete Example
Here’s a complete process management workflow:- Python
- JavaScript
Best Practices
1
1. Name Your Processes
Always name processes when starting them for easier identification in process lists.
2
2. Monitor Regularly
Check process status periodically to track progress and detect failures early.
3
3. Clean Up Completed Processes
Remove or archive completed processes to keep your process list manageable.
4
4. Handle Failures
Check for failed status and access stderr for error details when processes fail.
5
5. Kill Stuck Processes
Use
kill_process() to terminate processes that are stuck or taking too long.Related
- Background Execution - Start background processes
- Process Monitoring - Monitor system processes
- SDK: sandbox.list_processes() - Python SDK method
- SDK: sandbox.kill_process() - Python SDK method
- API: GET /execute/processes - VM Agent API endpoint
- API: DELETE /execute/kill - VM Agent API endpoint
- CLI Code Execution - Execute code from CLI
Next Steps
- Learn about Background Execution to start processes
- Explore Synchronous Execution for immediate results
- Review Streaming Execution for real-time monitoring

