def run(self):
        """ Runs the worker thread that records occupation updates to the
            database. """
        # TODO is a separate thread necessary?  Wouldn't a threadPool.execute
        #      suffice?
        self.running = True
        self.recordCond.acquire()
        while self.running or self.recordQueue:
            # Check for new entries.  If none: wait.
            if self.running and not self.recordQueue:
                self.recordCond.wait()
                continue
            entries = list(reversed(self.recordQueue))
            self.recordQueue = []
            self.recordCond.release()
            with self.lock:
                # Record the entries
                for now, updates, source in entries:
                    for pc, occupation in updates.iteritems():
                        self.c.execute(""" INSERT INTO occupationUpdates
                                            ( pc, datetime, occupation, source )
                                           VALUES ( ?, ?, ?, ? ) """, (
                                   self._id_for_pc(pc), now, occupation,
                                   self._id_for_source(source)))
                self.conn.commit()
            self.recordCond.acquire()
        self.recordCond.release()
def run ( self ) : self . running = True self . recordCond . acquire ( ) while self . running or self . recordQueue : if self . running and not self . recordQueue : self . recordCond . wait ( ) continue entries = list ( reversed ( self . recordQueue ) ) self . recordQueue = [ ] self . recordCond . release ( ) with self . lock : for now , updates , source in entries : for pc , occupation in updates . iteritems ( ) : self . c . execute ( """ INSERT INTO occupationUpdates
                                            ( pc, datetime, occupation, source )
                                           VALUES ( ?, ?, ?, ? ) """ , ( self . _id_for_pc ( pc ) , now , occupation , self . _id_for_source ( source ) ) ) self . conn . commit ( ) self . recordCond . acquire ( ) self . recordCond . release ( )
Runs the worker thread that records occupation updates to the
            database.