def cleanup(self):
    self.job_cache.clear()
    final_jobs = set(self.jobs)
    todelete = [job for job in self.dependencies if (job not in final_jobs)]
    for job in todelete:
        del self.dependencies[job]
        try:
            del self.depending[job]
        except KeyError:
            pass
def cleanup(self):
    self.job_cache.clear()
    final_jobs = set(self.jobs)
    todelete = [job for job in self.dependencies if (job not in final_jobs)]
    for job in todelete:
        del self.dependencies[job]
        try:
            del self.depending[job]
        except KeyError:
            pass