From: Mike O'Connor Date: Fri, 30 Oct 2009 12:03:07 +0000 (+0000) Subject: Merge commit 'public/knownchanges' into knownchanges X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=df610ec6b921b869c4e4a25629a0aff3f13a03ae;hp=-c;p=dak.git Merge commit 'public/knownchanges' into knownchanges --- df610ec6b921b869c4e4a25629a0aff3f13a03ae diff --combined dak/import_known_changes.py index 475c8f76,0391d974..b403a808 --- a/dak/import_known_changes.py +++ b/dak/import_known_changes.py @@@ -168,6 -168,10 +168,10 @@@ class ChangesGenerator(threading.Thread threading.Thread.__init__(self) self.queue = queue self.session = DBConn().session() + self.die = False + + def plsDie(self): + self.die = True def run(self): cnf = Config() @@@ -181,6 -185,9 +185,9 @@@ if not filenames: # Empty directory (or only subdirectories), next continue + if self.die: + return + for changesfile in filenames: if not changesfile.endswith(".changes"): # Only interested in changes files. @@@ -189,6 -196,7 +196,6 @@@ if not get_knownchange(changesfile, self.session): to_import = ChangesToImport(dirpath, changesfile, count) - print("enqueue: %s" % to_import) self.queue.enqueue(to_import) self.queue.enqueue(EndOfChanges()) @@@ -198,10 -206,16 +205,16 @@@ class ImportThread(threading.Thread) threading.Thread.__init__(self) self.queue = queue self.session = DBConn().session() + self.die = False + + def plsDie(self): + self.die = True def run(self): while True: try: + if self.die: + return to_import = self.queue.dequeue() if not to_import: return @@@ -211,6 -225,7 +224,6 @@@ changes = Changes() changes.changes_file = to_import.changesfile changesfile = os.path.join(to_import.dirpath, to_import.changesfile) - print( "STU: %s / %s" % (to_import.dirpath, to_import.changesfile)) changes.changes = parse_changes(changesfile, signing_rules=-1) changes.changes["fingerprint"] = check_signature(changesfile) changes.add_known_changes(to_import.dirpath, self.session) @@@ -266,10 -281,25 +279,25 @@@ def main() queue = OneAtATime() - ChangesGenerator(queue).start() + threads = [ ChangesGenerator(queue) ] for i in range(num_threads): - ImportThread(queue).start() + threads.append( ImportThread(queue) ) + + try: + for thread in threads: + thread.start() + + for thread in thrads: + thread.join() + + except KeyboardInterrupt: + utils.warn("Caught C-c; terminating.") + for thread in threads: + thread.plsDie() + + for thread in threads: + thread.join() if __name__ == '__main__':