From 40714ca0fa5c9ca6fbfb0f9d896918f0e3e30a05 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 31 Mar 2013 17:44:51 -0400 Subject: [PATCH] fix locking --- python/devsup/db.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/python/devsup/db.py b/python/devsup/db.py index 91289cf..f21f6c5 100644 --- a/python/devsup/db.py +++ b/python/devsup/db.py @@ -76,29 +76,29 @@ def _default_whendone(type, val, tb): class IOScanListThread(IOScanListBlock): _worker = None + _worker_lock = threading.Lock() queuelength=100 @classmethod def getworker(cls): - if cls._worker: - return cls._worker - import hooks - T = Worker(max=cls.queuelength) - hooks.addHook('AtIocExit', T.join) - T.start() - cls._worker = T - return T + with cls._worker_lock: + if cls._worker: + return cls._worker + import hooks + T = Worker(max=cls.queuelength) + hooks.addHook('AtIocExit', T.join) + T.start() + cls._worker = T + return T def __init__(self): super(IOScanListThread,self).__init__() self._lock = threading.Lock() def add(self, rec): - print self,'add',rec with self._lock: return super(IOScanListThread,self).add(rec) def _remove(self, rec): - print self,'remove',rec with self._lock: return super(IOScanListThread,self)._remove(rec)