Created
November 26, 2018 06:09
-
-
Save balaprasanna/9d1b2bc76de0a20c23d5904dfd6a3400 to your computer and use it in GitHub Desktop.
Scale python script with Golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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