Documentation IndexFetch the complete documentation index at: /docs/llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
commands.run()
background
commands.kill()
import { Sandbox } from 'ppio-sandbox/code-interpreter' const sandbox = await Sandbox.create() // 在后台运行命令 const command = await sandbox.commands.run('echo hello; sleep 10; echo world', { background: true, onStdout: (data) => { console.log(data) }, }) // 终止命令 await command.kill() await sandbox.kill()
from ppio_sandbox.code_interpreter import Sandbox sandbox = Sandbox.create() # 在后台运行命令 command = sandbox.commands.run('echo hello; sleep 10; echo world', background=True) # 获取命令运行在后台的 stdout 和 stderr。 # 您可以在单独的线程中运行此代码,或使用 command.wait() 等待命令被执行完。 for stdout, stderr, _ in command: if stdout: print(stdout) if stderr: print(stderr) # 终止命令 command.kill() sandbox.kill()