[Yum-devel] [patch] leaking yum.log fd when instantiating multiple YumBase objects
James Antill
james at fedoraproject.org
Fri Jun 17 15:35:55 UTC 2011
On Fri, 2011-06-17 at 10:45 -0400, Zdenek Pavlas wrote:
> Should fix https://bugzilla.redhat.com/show_bug.cgi?id=713924
> Very ugly, I know, but it seems to work. Any better ideas?
Looks great to me, thanks! Just a couple of minor comments:
Add "BZ 713924" to the end of the commit summary.
>Turn 'cleanup' to '_cleanup'?
Yeh, probably ... at least for now.
> --- yum-3.4.1/yum/__init__.py.old 2011-06-17 16:31:49.014599854 +0200
> +++ yum-3.4.1/yum/__init__.py 2011-06-17 16:36:23.355599854 +0200
> @@ -203,11 +203,13 @@ class YumBase(depsolve.Depsolve):
> self.prerepoconf = _YumPreRepoConf()
>
> self.run_with_package_names = set()
> + self.cleanup = []
>
> def __del__(self):
> self.close()
> self.closeRpmDB()
> self.doUnlock()
> + [i() for i in self.cleanup] # close leaks
Just make this a normal for loop, and call "i" at least "cb".
> def close(self):
> # We don't want to create the object, so we test if it's been created
> @@ -375,7 +377,7 @@ class YumBase(depsolve.Depsolve):
> syslog_device)
>
> def doFileLogSetup(self, uid, logfile):
> - logginglevels.setFileLog(uid, logfile)
> + logginglevels.setFileLog(uid, logfile, self.cleanup)
>
> def getReposFromConfigFile(self, repofn, repo_age=None, validate=None):
> """read in repositories from a config .repo file"""
> diff -up yum-3.4.1/yum/logginglevels.py.old yum-3.4.1/yum/logginglevels.py
> --- yum-3.4.1/yum/logginglevels.py.old 2011-06-17 16:32:03.860599957 +0200
> +++ yum-3.4.1/yum/logginglevels.py 2011-06-17 16:38:33.906599869 +0200
> @@ -186,7 +186,7 @@ def doLoggingSetup(debuglevel, errorleve
> if errorlevel is not None:
> setErrorLevel(errorlevel)
>
> -def setFileLog(uid, logfile):
> +def setFileLog(uid, logfile, cleanup = [])
Remove the spaces from func. argument init.
This is also a python gotcha:
http://stackoverflow.com/questions/2170684/python-init-argument-problem
More information about the Yum-devel
mailing list