'Checks the task\'s config hash and updates the hash if necessary.'

def check_config_hash(self):

    config_hash = get_config_hash(self.config)
    if self.is_rerun:
        if self.prepared_config:
            self.config = copy.deepcopy(self.prepared_config)
        else:
            log.error(u'BUG:    No    prepared_config    on    rerun,    please    report.')
    with Session() as session:
        last_hash = session.query(TaskConfigHash).filter((TaskConfigHash.task == self.name)).first()
        if (not last_hash):
            session.add(TaskConfigHash(task=self.name, hash=config_hash))
            self.config_changed()
        elif (last_hash.hash != config_hash):
            last_hash.hash = config_hash
            self.config_changed()
