ensure the pipe is closed when we are done with the subprocess
authorRalf Jung <post@ralfj.de>
Sun, 15 Sep 2013 13:22:20 +0000 (15:22 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 15 Sep 2013 13:22:20 +0000 (15:22 +0200)
auto_debuild.py

index a7087985b285161ee58fa607045526e3aad0cde5..bee82caa859df4fc1759e937bc038a1a4fb8136b 100755 (executable)
@@ -177,9 +177,9 @@ def commandInBuildEnv(config, command):
 
 def getArchitecture(config):
        cmd = commandInBuildEnv(config, ['dpkg-architecture', '-qDEB_HOST_ARCH'])
-       p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
-       res = p.communicate()[0] # get only stdout
-       if p.returncode != 0: raise Exception("Querying dpkg for the architecture failed")
+       with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p:
+               res = p.communicate()[0] # get only stdout
+               if p.returncode != 0: raise Exception("Querying dpkg for the architecture failed")
        return res[0:len(res)-1] # chop of the \n at the end
 
 def writeDependency(f, name, list):