Yeuoly 1 anno fa
parent
commit
0e380bc12f
2 ha cambiato i file con 7 aggiunte e 7 eliminazioni
  1. 6 6
      cmd/test/sandbox/main.go
  2. 1 1
      internal/static/syscalls.go

+ 6 - 6
cmd/test/sandbox/main.go

@@ -11,15 +11,16 @@ import (
 const python_script = `def foo(a, b):
 	return a + b
 print(foo(1, 2))
-
 import json
 import os
-print(json.dumps({"a": 1, "b": 2}))
+import time
+print(json.dumps({"a": 1, "b": 2}), flush=True)
+time.sleep(3)
 `
 
 func main() {
 	runner := python.PythonRunner{}
-	stdout, stderr, done, err := runner.Run(python_script, time.Minute, nil)
+	stdout, stderr, done, err := runner.Run(python_script, time.Second*10, nil)
 	if err != nil {
 		log.Panic("failed to run python script: %v", err)
 	}
@@ -27,12 +28,11 @@ func main() {
 	for {
 		select {
 		case <-done:
-			fmt.Println("done")
 			return
 		case out := <-stdout:
-			fmt.Print(string(out))
+			fmt.Println(string(out))
 		case err := <-stderr:
-			fmt.Print(string(err))
+			fmt.Println(string(err))
 		}
 	}
 }

+ 1 - 1
internal/static/syscalls.go

@@ -22,5 +22,5 @@ var ALLOW_SYSCALLS = []int{
 	syscall.SYS_TGKILL, syscall.SYS_RT_SIGACTION,
 	// time
 	syscall.SYS_CLOCK_GETTIME, syscall.SYS_GETTIMEOFDAY, syscall.SYS_TIME, syscall.SYS_NANOSLEEP,
-	syscall.SYS_EPOLL_CTL,
+	syscall.SYS_EPOLL_CTL, syscall.SYS_CLOCK_NANOSLEEP, syscall.SYS_PSELECT6,
 }