Hello. My very first post here, so hi all! I am also new to Go, so please excuse my basic questions.
I am trying to run (just to check how it works) a Python script from go using exec.Command().Run(). It works fine in a regular way, as below. The Python script is as follows:
import time
if __name__ == '__main__':
time.sleep(3)
print("Python job finished")
Yup, now I see that I have to take care of not finishing the main goroutine before the others. Enough to add time.Sleep() to the main goroutine:
func main() {
go RunPython("job.py")
time.Sleep(10 * time.Second)
}
This was enough for Python’s job to finish. I know this is not the best way to synchronize routines, but it helped me understand this simple thing. Thank you!