From 816fbaf42407fbbb8466c0d08d64fc11f605e5b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 28 Jan 2009 13:13:56 +0100 Subject: Use the new database class layout --- portato/db/database.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'portato/db/database.py') diff --git a/portato/db/database.py b/portato/db/database.py index 7d8e378..941c3a3 100644 --- a/portato/db/database.py +++ b/portato/db/database.py @@ -12,6 +12,9 @@ from __future__ import absolute_import, with_statement +from threading import RLock +from functools import wraps + class PkgData (object): __slots__ = ("cat", "pkg", "inst") @@ -33,6 +36,20 @@ class Database (object): ALL = _("ALL") + def __init__ (self): + self._lock = RLock() + + @staticmethod + def lock (f): + @wraps(f) + def wrapper (self, *args, **kwargs): + with self._lock: + r = f(self, *args, **kwargs) + + return r + + return wrapper + def populate (self, category = None): """Populates the database. -- cgit v1.2.3