commands.run() 方法传递 onStdout、onStderr 回调,或在 Python 中向 commands.run() 方法传递 on_stdout、on_stderr 回调。
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
commands.run() 方法传递 onStdout、onStderr 回调,或在 Python 中向 commands.run() 方法传递 on_stdout、on_stderr 回调。
import { Sandbox } from 'ppio-sandbox/code-interpreter'
const sandbox = await Sandbox.create()
const result = await sandbox.commands.run('echo hello; sleep 1; echo world', {
onStdout: (data) => {
console.log(data)
},
onStderr: (data) => {
console.log(data)
},
})
console.log(result)
await sandbox.kill()
from ppio_sandbox.code_interpreter import Sandbox
sandbox = Sandbox.create()
result = sandbox.commands.run('echo hello; sleep 1; echo world',
on_stdout=lambda data: print(
data),
on_stderr=lambda data: print(data))
print(result)
sandbox.kill()