1234567891011121314151617181920212223242526272829303132333435363738 |
- package main
- import (
- "fmt"
- "time"
- "github.com/langgenius/dify-sandbox/internal/core/runner/python"
- "github.com/langgenius/dify-sandbox/internal/utils/log"
- )
- const python_script = `import os
- import sys
- os.write(sys.stderr.fi)`
- func main() {
- runner := python.PythonRunner{}
- stdout, stderr, done, err := runner.Run(python_script, time.Second*10, nil)
- if err != nil {
- log.Panic("failed to run python script: %v", err)
- }
- for {
- select {
- case <-done:
- return
- case out := <-stdout:
- if string(out) != "" {
- fmt.Println(string(out))
- }
- case err := <-stderr:
- if string(err) != "" {
- fmt.Println(string(err))
- }
- }
- }
- }
|