def delete(self):
        os.remove(self.getJobFileName()) #This is the atomic operation, if this file is not present the job is deleted.
        dirToRemove = self.jobDir
        while 1:
            head, tail = os.path.split(dirToRemove)
            if re.match("t[0-9]+$", tail):
                command = "rm -rf %s" % dirToRemove
            else:
                command = "rm -rf %s/*" % dirToRemove #We're at the root
            try:
                system(command)
            except RuntimeError:
                pass #This is not a big deal, as we expect collisions
            dirToRemove = head
            try:
                if len(os.listdir(dirToRemove)) != 0:
                    break
            except os.error: #In case stuff went wrong, but as this is not critical we let it slide
                break
Removes from disk atomically, can not then subsequently call read(), write() or addChildren()
dataset/ETHPy150Open benedictpaten/jobTree/src/job.py/Job.delete