From: Ralf Jung <post@ralfj.de>
Date: Sun, 15 Sep 2013 13:22:20 +0000 (+0200)
Subject: ensure the pipe is closed when we are done with the subprocess
X-Git-Url: https://git.ralfj.de/auto-debuild.git/commitdiff_plain/f10524d6b291b01312cd5d00df1f147844612dd5?ds=sidebyside

ensure the pipe is closed when we are done with the subprocess
---

diff --git a/auto_debuild.py b/auto_debuild.py
index a708798..bee82ca 100755
--- a/auto_debuild.py
+++ b/auto_debuild.py
@@ -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):