Issue 3335: subprocess lib - opening same command fails (original) (raw)

When I make the same shell call a second time, a weird error occurs.
It appears that the system is caching the call and then returning the same object the second time, which causes a problem because the stream is at EOF and there is no way to seek on this sort of file object.

Code: fout = subprocess.Popen("owplaces -silent -multi", shell=True, stdout=subprocess.PIPE).stdout self.output = fout.read()

    if self.output != []:
        for line in self.output:
            print line
    
    fout.close()

Error: Traceback (most recent call last): File "./saveSettings.py", line 30, in next_page func() File "./saveSettings.py", line 62, in save_startup fout = subprocess.Popen("owplaces -silent -multi", shell=True, stdout=subprocess.PIPE).stdout File "/opt/app/g++lib6/python-2.4/lib/python2.4/warnings.py", line 61, in warn warn_explicit(message, category, filename, lineno, module, registry) File "/opt/app/g++lib6/python-2.4/lib/python2.4/warnings.py", line 82, in warn_explicit for item in filters: TypeError: an integer is required

The first time the code works time. The second (and subsequent times) the cryptic error msg is displayed.

Python 2.4.5 running on a Solaris machine.