I want to use a go executable: timescaledb-parallel-copy to insert data into database from a csv file. However, I plan to use Python for reading in the filename and lookup the appropriate table name for insertion. If I then launch timescaledb-parallel-copy as a Python subprocess to execute on shell, will it still be parallel? I do not need Python to make it parallel, it is parallel by default. I just do not want Python to make it single-threaded.
2 Answers
If you are using subprocess.run() then your program, timescaledb-parallel-copy will execute as if you had called it from the shell. It will still be in parallel. The python script will not be, and will wait on timescaledb-parallel-copy to return.
1 Comment
Chintan Pathak
I was able to test that the subprocess runs in parallel if it wants to.
shell=False, there's no shell involved anywhere, just the Python interpreterfork()ing itself andexecve()ing the Go program -- and even if you're doing it wrong and usingshell=True, the shell that the Python interpreterfork()s andexec()s is justfork()ing off a copy of itself and usingexecve()to replace that copy with the Go executable's process image).