@@ -8,10 +8,17 @@ import (
)
var (
- queue chan bool = make(chan bool, static.GetCoshubGlobalConfigurations().MaxWorkers)
+ queue chan bool
+func InitSandBoxQueue() {
+ if queue == nil {
+ queue = make(chan bool, static.GetCoshubGlobalConfigurations().MaxWorkers)
+ }
+}
+
func RunSandboxController(c *gin.Context) {
BindRequest(c, func(req struct {
Language string `json:"language" form:"language" binding:"required"`
Code string `json:"code" form:"code" binding:"required"`
@@ -137,7 +137,6 @@ func (p *PythonRunner) Run(code string, timeout time.Duration, stdin []byte) (ch
go func() {
var status syscall.WaitStatus
_, err := syscall.Wait4(int(pid), &status, 0, nil)
- time.Sleep(time.Second)
if err != nil {
done <- err
return
@@ -26,6 +26,7 @@ func initServer() {
r := gin.Default()
controller.Setup(r)
+ controller.InitSandBoxQueue()
r.Run(fmt.Sprintf(":%d", config.App.Port))
}