'Atomic test-and-set -- grab the lock if it is not set,
return True if it succeeded.'

def testandset(self):

    if (not self.locked):
        self.locked = True
        return True
    else:
        return False
