From af1f4801edfb479d83f90683dfb798f618730762 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 29 Apr 2010 16:42:27 +0200 Subject: [PATCH] Add database interface to queue class. --- cappie/queue.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cappie/queue.py b/cappie/queue.py index e2d0dd6..cdd0090 100644 --- a/cappie/queue.py +++ b/cappie/queue.py @@ -23,6 +23,7 @@ import time from threading import Thread +from database import Database from errors import * class Queue(Thread): @@ -37,6 +38,8 @@ class Queue(Thread): self.__running = True self.__queue = [] + self.db = Database(log) + def __len__(self): return self.length @@ -53,6 +56,8 @@ class Queue(Thread): def run(self): self.log.debug("Started event queue") + self.db.open() + while self.__running or self.__queue: if not self.__queue: #self.log.debug("Queue sleeping for %s seconds" % self.heartbeat) @@ -66,6 +71,8 @@ class Queue(Thread): except EventException, e: self.log.error("Catched event exception: %s" % e) + self.db.close() + def shutdown(self): self.__running = False self.log.debug("Shutting down queue") -- 2.39.2