I have a Python script, which calls a Perl script that parses some files and produces output files. Again these output files are uploaded into MySQL database using the Python script. The Perl script takes around 5-7 mins to parse some files and produce the output files that the Python uses to upload.
The Python script is like:
import subprocess
pipe = subprocess.Popen(["perl", "./parser.pl"], stdin=subprocess.PIPE)
pipe.stdin.close()
#Now, load the output files from parser.pl to database.
sql01 = """LOAD DATA LOCAL INFILE 'sequence.parsed' INTO TABLE nasequenceimp FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';"""
try:
c.execute(sql01)
conn.commit()
except StandardError, e:
print e
conn.rollback()
But, it seems that Python script is terminated and the Perl script continues to parse the files. So, Python shoots error sequence.parsed does not exist
Why is the Python script not waiting for the Perl to complete executing?