python.go 601 B

123456789101112131415161718192021222324252627282930
  1. package python
  2. import (
  3. _ "embed"
  4. "fmt"
  5. "syscall"
  6. "time"
  7. "github.com/langgenius/dify-sandbox/internal/core/runner"
  8. )
  9. type PythonRunner struct {
  10. runner.Runner
  11. runner.SeccompRunner
  12. }
  13. //go:embed prescript.py
  14. var python_sandbox_fs []byte
  15. func (p *PythonRunner) Run(code string, timeout time.Duration, stdin chan []byte) (<-chan []byte, <-chan []byte, error) {
  16. err := p.WithSeccomp(func() error {
  17. syscall.Exec("/usr/bin/python3", []string{"/usr/bin/python3", "./internal/core/runner/python/prescript.py"}, nil)
  18. return nil
  19. })
  20. if err != nil {
  21. fmt.Println(err)
  22. }
  23. return nil, nil, nil
  24. }