[PATCH] bug fix: instantiate the Yum manager when update the yum packages list

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> an instance just refresh packagekit once. for example: $ sudo PYTHONPATH=src python -c '
from yum import YumBase YumBase().doPackageLists("updates") _yb = YumBase() _yb.doPackageLists("updates") _yb.doPackageLists("updates") ' Loaded plugins: langpacks, refresh-packagekit Loaded plugins: langpacks, refresh-packagekit
you can seen the second _yb.doPackageLists will not refresh packagekit. The apt manager may also has the same problem. But not test it on ubuntu, will send a patch later after I have check. Signed-off-by: Aline Manera <alinefm@br.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/swupdate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kimchi/swupdate.py b/src/kimchi/swupdate.py index ff5c9d1..dc48153 100644 --- a/src/kimchi/swupdate.py +++ b/src/kimchi/swupdate.py @@ -136,14 +136,14 @@ class YumUpdate(object): """ def __init__(self): self._pkgs = {} - self._yb = getattr(__import__('yum'), 'YumBase')() + self._yb = getattr(__import__('yum'), 'YumBase') self.update_cmd = ["yum", "-y", "update"] def _refreshUpdateList(self): """ Update the list of packages to be updated in the system. """ - self._pkgs = self._yb.doPackageLists('updates') + self._pkgs = self._yb().doPackageLists('updates') def getPackagesList(self): """ -- 1.8.5.3

On 03/14/2014 10:52 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
an instance just refresh packagekit once. But there maybe another problem. When software update, the yum will be locked. will' not get the Package Lists? Need to try.
for example: $ sudo PYTHONPATH=src python -c '
from yum import YumBase YumBase().doPackageLists("updates") _yb = YumBase() _yb.doPackageLists("updates") _yb.doPackageLists("updates") ' Loaded plugins: langpacks, refresh-packagekit Loaded plugins: langpacks, refresh-packagekit
you can seen the second _yb.doPackageLists will not refresh packagekit.
The apt manager may also has the same problem. But not test it on ubuntu, will send a patch later after I have check.
Signed-off-by: Aline Manera <alinefm@br.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/swupdate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/swupdate.py b/src/kimchi/swupdate.py index ff5c9d1..dc48153 100644 --- a/src/kimchi/swupdate.py +++ b/src/kimchi/swupdate.py @@ -136,14 +136,14 @@ class YumUpdate(object): """ def __init__(self): self._pkgs = {} - self._yb = getattr(__import__('yum'), 'YumBase')() + self._yb = getattr(__import__('yum'), 'YumBase') self.update_cmd = ["yum", "-y", "update"]
def _refreshUpdateList(self): """ Update the list of packages to be updated in the system. """ - self._pkgs = self._yb.doPackageLists('updates') + self._pkgs = self._yb().doPackageLists('updates')
def getPackagesList(self): """
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

On 03/15/2014 12:23 AM, Sheldon wrote:
On 03/14/2014 10:52 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
an instance just refresh packagekit once. But there maybe another problem. When software update, the yum will be locked. will' not get the Package Lists? Need to try. Have try: YumBase().doPackageLists("updates") do not need to get the lock.
1. install a package. $sudo yum install xxxx 2. can not check-update. $ sudo yum check-update Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum Memory : 68 M RSS (384 MB VSZ) Started: Mon Mar 17 12:54:36 2014 - 31:16 ago State : Sleeping, pid: 10459 3. but doPackageLists can work, it does not need to get the lock of yum. $ sudo PYTHONPATH=src python -c '
from yum import YumBase YumBase().doPackageLists("updates") '
for example: $ sudo PYTHONPATH=src python -c '
from yum import YumBase YumBase().doPackageLists("updates") _yb = YumBase() _yb.doPackageLists("updates") _yb.doPackageLists("updates") ' Loaded plugins: langpacks, refresh-packagekit Loaded plugins: langpacks, refresh-packagekit
you can seen the second _yb.doPackageLists will not refresh packagekit.
The apt manager may also has the same problem. But not test it on ubuntu, will send a patch later after I have check.
Signed-off-by: Aline Manera <alinefm@br.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/swupdate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/swupdate.py b/src/kimchi/swupdate.py index ff5c9d1..dc48153 100644 --- a/src/kimchi/swupdate.py +++ b/src/kimchi/swupdate.py @@ -136,14 +136,14 @@ class YumUpdate(object): """ def __init__(self): self._pkgs = {} - self._yb = getattr(__import__('yum'), 'YumBase')() + self._yb = getattr(__import__('yum'), 'YumBase') self.update_cmd = ["yum", "-y", "update"]
def _refreshUpdateList(self): """ Update the list of packages to be updated in the system. """ - self._pkgs = self._yb.doPackageLists('updates') + self._pkgs = self._yb().doPackageLists('updates')
def getPackagesList(self): """
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

于 2014年03月14日 22:52, shaohef@linux.vnet.ibm.com 写道:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
an instance just refresh packagekit once.
for example: $ sudo PYTHONPATH=src python -c '
from yum import YumBase YumBase().doPackageLists("updates") _yb = YumBase() _yb.doPackageLists("updates") _yb.doPackageLists("updates") ' Loaded plugins: langpacks, refresh-packagekit Loaded plugins: langpacks, refresh-packagekit
you can seen the second _yb.doPackageLists will not refresh packagekit.
The apt manager may also has the same problem. But not test it on ubuntu, will send a patch later after I have check.
Signed-off-by: Aline Manera <alinefm@br.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/swupdate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/swupdate.py b/src/kimchi/swupdate.py index ff5c9d1..dc48153 100644 --- a/src/kimchi/swupdate.py +++ b/src/kimchi/swupdate.py @@ -136,14 +136,14 @@ class YumUpdate(object): """ def __init__(self): self._pkgs = {} - self._yb = getattr(__import__('yum'), 'YumBase')() + self._yb = getattr(__import__('yum'), 'YumBase') self.update_cmd = ["yum", "-y", "update"]
def _refreshUpdateList(self): """ Update the list of packages to be updated in the system. """ - self._pkgs = self._yb.doPackageLists('updates') + self._pkgs = self._yb().doPackageLists('updates')
def getPackagesList(self): """
I'd suggest you delete self._yb = getattr(__import__('yum'), 'YumBase') from __init__(), and move it to _refreshUpdateList(), then change the _yb to a local variable. The _yb is only used in _refreshUpdateList(), it should not be a data member of the YumUpdate object. Some for the AptUpdate. -- Thanks and best regards! Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397
participants (4)
-
Aline Manera
-
shaohef@linux.vnet.ibm.com
-
Sheldon
-
Zhou Zheng Sheng