summaryrefslogtreecommitdiffstats
path: root/pym/_emerge
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-08-25 15:10:52 -0700
committerZac Medico <zmedico@gentoo.org>2011-08-25 15:10:52 -0700
commita509ffd891642b3353a6160ba04057272b48dc2c (patch)
tree29beb8441dff815b97938ad472c86c1fe4602f71 /pym/_emerge
parent3735e3e1805769fcaae2ef450907db7508355ec9 (diff)
downloadportage-a509ffd891642b3353a6160ba04057272b48dc2c.tar.gz
portage-a509ffd891642b3353a6160ba04057272b48dc2c.tar.bz2
portage-a509ffd891642b3353a6160ba04057272b48dc2c.zip
python3.2 fixes: ResourceWarning: unclosed file
Diffstat (limited to 'pym/_emerge')
-rw-r--r--pym/_emerge/AsynchronousLock.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLock.py
index 637ba7381..be498b802 100644
--- a/pym/_emerge/AsynchronousLock.py
+++ b/pym/_emerge/AsynchronousLock.py
@@ -209,9 +209,22 @@ class _LockProcess(AbstractPollTask):
os.close(in_pw)
def _proc_exit(self, proc):
+
+ if self._files is not None:
+ # Close pipe_out if it's still open, since it's useless
+ # after the process has exited. This helps to avoid
+ # "ResourceWarning: unclosed file" since Python 3.2.
+ try:
+ pipe_out = self._files.pop('pipe_out')
+ except KeyError:
+ pass
+ else:
+ pipe_out.close()
+
if proc.returncode != os.EX_OK:
# Typically, this will happen due to the
# process being killed by a signal.
+
if not self._acquired:
# If the lock hasn't been aquired yet, the
# caller can check the returncode and handle