I want to get the uncompressed file size of a tar.gz file which is larger than 4GB in size. I found a shell command to do the same and the shell command works perfectly fine. But when I use the same command in my python program it never completes.
I am running the script on RHEL 6.8.
Command to get the correct uncompressed file size
gzip -dc some_tar_gz.tar.gz | wc -c
My python script
import subprocess
import shlex
from pprint import pprint
command_list = shlex.split("gzip -dc some_tar_gz.tar.gz | wc -c")
result = subprocess.Popen(command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
out, err = result.communicate()
pprint(out)
The above gzip command returned the uncompressed file size in under 5 mins. But the above python script didn't return any result even after 1 hour.
Edit 1:
When I removed shell=True
and saw the result of top
command python process was taking around 27GB VIRT after that the process was automatically killed. I got the problem but I don't know how to resolve this.