# authors: Ahmed Kamal # Jonathan Dieter # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Copyright 2007 Ahmed Kamal, Jonathan Dieter import threading class ReconstructionThread(threading.Thread): def __init__(self, queue, lock, run_function): threading.Thread.__init__(self) self.run_function = run_function self.queue = queue self.lock = lock self.can_exit = False self.messages = "" def run(self): while True: try: retval = self.queue.get(not self.can_exit) except: # If we're done with our drpms and no more are coming, let's # blow this joint break if retval != None: messages = apply(self.run_function, retval) if self.can_exit: # If there are not going to be any more new drpms, # send messages directly to conduit conduit = retval[0] if self.messages != "": conduit.info(2, self.messages[:-1]) self.messages = "" conduit.info(2, messages[:-1]) else: # We may be downloading drpms still, so queue messages self.lock.acquire() self.messages += messages self.lock.release()