Skip to content

Instantly share code, notes, and snippets.

@balaprasanna
Created November 26, 2018 06:09
Show Gist options
  • Select an option

  • Save balaprasanna/9d1b2bc76de0a20c23d5904dfd6a3400 to your computer and use it in GitHub Desktop.

Select an option

Save balaprasanna/9d1b2bc76de0a20c23d5904dfd6a3400 to your computer and use it in GitHub Desktop.
Scale python script with Golang
package main
import (
"fmt"
"time"
"sync"
"os/exec"
)
var wg sync.WaitGroup
func preprocessing(n int) {
defer wg.Done()
fmt.Printf(">>>>>> %d \n", n)
out, err := exec.Command("python","app.py").Output()
if err != nil {
fmt.Println("error occured")
fmt.Printf("%s", err)
}
fmt.Printf(">>>>>> %s \n", out)
// time.Sleep(time.Second * time.Duration(7))
}
func main() {
start := time.Now()
for i := 0; i < 100; i++ {
wg.Add(1)
go preprocessing(i)
}
wg.Wait()
elapsed := time.Since(start)
fmt.Printf("Preprocessing took %s", elapsed)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment