[Yum-devel] [PATCH] Explicitly close sqlite, adds .close() and calls it on delete (BZ 525297)

Seth Vidal skvidal at fedoraproject.org
Wed Sep 23 21:25:03 UTC 2009



On Wed, 23 Sep 2009, James Antill wrote:

> ---
> yum/__init__.py |    4 ++++
> yum/history.py  |    8 ++++++++
> 2 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/yum/__init__.py b/yum/__init__.py
> index 244f83f..35da1fb 100644
> --- a/yum/__init__.py
> +++ b/yum/__init__.py
> @@ -163,6 +163,10 @@ class YumBase(depsolve.Depsolve):
>         self.doUnlock()
>
>     def close(self):
> +        # We don't want to create the object, so we test if it's been created
> +        if self._history is not None:
> +            self.history.close()
> +
>         if self._repos:
>             self._repos.close()
>
> diff --git a/yum/history.py b/yum/history.py
> index ea3a464..482587e 100644
> --- a/yum/history.py
> +++ b/yum/history.py
> @@ -215,6 +215,9 @@ class YumHistory:
>         if self._db_file is None:
>             self._create_db_file()
>
> +    def __del__(self):
> +        self.close()
> +
>     def _get_cursor(self):
>         if self._conn is None:
>             self._conn = sqlite.connect(self._db_file)
> @@ -222,6 +225,11 @@ class YumHistory:
>     def _commit(self):
>         return self._conn.commit()
>
> +    def close(self):
> +        if self._conn is not None:
> +            self._conn.close()
> +            self._conn = None
> +
>     def _pkgtup2pid(self, pkgtup, checksum=None):
>         cur = self._get_cursor()
>         executeSQL(cur, """SELECT pkgtupid, checksum FROM pkgtups


ACK.
-sv



More information about the Yum-devel mailing list