def METHOD_NAME(self, lease_duration=-1):
    if self.lease is None:
        self.lease = random.randint(0, 2**9)
        try:
            yield self.lease
        finally:
            self.lease = None
    else:
        raise Exception("Lease already held")