[Kimchi-devel] [PATCH 2/2] Add lock in swupdate

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Wed Mar 26 10:50:02 UTC 2014


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

Add apt system lock to swupdate.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/swupdate.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/kimchi/swupdate.py b/src/kimchi/swupdate.py
index e2fdc29..bd0d4e9 100644
--- a/src/kimchi/swupdate.py
+++ b/src/kimchi/swupdate.py
@@ -184,6 +184,7 @@ class AptUpdate(object):
     """
     def __init__(self):
         self._pkgs = {}
+        self.pkg_lock = getattr(__import__('apt_pkg'), 'SystemLock')
         self.update_cmd = ['apt-get', 'upgrade', '-y']
 
     def _refreshUpdateList(self):
@@ -191,9 +192,10 @@ class AptUpdate(object):
         Update the list of packages to be updated in the system.
         """
         apt_cache = getattr(__import__('apt'), 'Cache')()
-        apt_cache.update()
-        apt_cache.upgrade()
-        self._pkgs = apt_cache.get_changes()
+        with self.pkg_lock():
+            apt_cache.update()
+            apt_cache.upgrade()
+            self._pkgs = apt_cache.get_changes()
 
     def getPackagesList(self):
         """
-- 
1.8.3.2




More information about the Kimchi-devel mailing list