From: Mike O'Connor Date: Fri, 30 Oct 2009 12:00:51 +0000 (+0100) Subject: import known_changes with correct name. catch keybord exception X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=a1e2a8958a1e3f2ed343396a53a8b6bd27262a6e;p=dak.git import known_changes with correct name. catch keybord exception Signed-off-by: Mike O'Connor --- diff --git a/dak/import_known_changes.py b/dak/import_known_changes.py index dcd3a335..0391d974 100755 --- a/dak/import_known_changes.py +++ b/dak/import_known_changes.py @@ -168,6 +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 @@ class ChangesGenerator(threading.Thread): 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. @@ -199,10 +206,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 @@ -268,10 +281,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__': diff --git a/daklib/changes.py b/daklib/changes.py index 2413bf4c..90ce2311 100755 --- a/daklib/changes.py +++ b/daklib/changes.py @@ -215,7 +215,7 @@ class Changes(object): distribution, urgency, maintainer, fingerprint, changedby, date) VALUES (:changesfile,:filetime,:source,:binary, :architecture, :version,:distribution,:urgency,:maintainer,:fingerprint,:changedby,:date)""", - { 'changesfile':changesfile, + { 'changesfile':self.changes_file, 'filetime':filetime, 'source':self.changes["source"], 'binary':self.changes["binary"],