的正确方法
我正在尝试用.gz扩展名来解压缩焦油文件
status = subprocess.call('tar -zvxf %s -C %s 2> /dev/null' % (zipped_tar_file,data_path), shell=True)
此语句后不久,我有另一个呼叫 -
status = subprocess.call('psql -q -v PATH=%s -f %s -h %s -p %d %s' %(some params)
第二个语句告诉Postgres使用第一个命令提取的一些文件。我在Postgres中发现一个不存在错误。
看来,在第二个语句启动时,tar命令仍在运行,而Postgres找不到尚未提取的所需文件。
ERROR: could not open file "path/filename.csv" for reading: No such file or directory
filename.csv
是要从TARBALL提取的文件之一。
这些文件有点重(很少被兆字节刺伤)
这是使用subprocess.call
?
as subprocess.call()花时间执行您可以在执行两个命令之间添加时间延迟。
您可以检查:Python子过程超时吗?有关更详细的答案。