X-Git-Url: http://git.ipfire.org/?p=oddments%2Fcappie.git;a=blobdiff_plain;f=cappie%2Fqueue.py;fp=cappie%2Fqueue.py;h=cdd0090b063edd845507540e79f9ffc12b03f169;hp=e2d0dd6486599067895814c65c50fd26d76913ba;hb=af1f4801edfb479d83f90683dfb798f618730762;hpb=53fd7d33da2e486eaa0a1d02ead61d544112ed8c 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")