stats locking

This commit is contained in:
Dan Ballard 2012-04-07 16:43:54 -07:00
parent e51a76116e
commit 21f62fd994
1 changed files with 20 additions and 0 deletions

View File

@ -20,6 +20,7 @@
# along with System-Monitoring-Daemon. If not, see <http://www.gnu.org/licenses/>.
##
import threading
from socket import *
HOST = ''
@ -31,8 +32,27 @@ MAX_QUEUE = 5
class Stats:
def __init__(self):
self.read_lock = threading.Lock()
self.write_lock = threading.Lock()
self.cpu_load = 50
def acquire_read(self):
self.read_lock.acquire()
self.write_lock.acquire()
def release_read(self):
self.write_lock.release()
self.read_lock.release()
def acquire_write(self):
self.write_lock.acquire()
def release_write(self):
self.write_lock.release()
class ClientHandler:
def __init__(self, stats):
self.stats = stats