def run(self): for i, id_ in enumerate(self.annotation_map): if not self.keep_going: break bm = Device.UserAnnotation(self.annotation_map[id_][0], self.annotation_map[id_][1]) try: self.device.add_annotation_to_library(self.db, id_, bm) except: import traceback self.errors[id_] = traceback.format_exc() self.update_progress.emit(i) self.update_done.emit() self.done_callback(list(self.annotation_map.keys()), self.errors)