ExecutorLease¶
- class ExecutorLease(*, manager, lease_id, owner, lease_seconds, grace_seconds, leased_at)[source]¶
Bases:
objectLease object returned by LeasedExecutorManager.acquire().
- Parameters:
Manual summary¶
lease.lease_idUnique lease identifier.
lease.ownerOptional owner label.
lease.lease_secondsRequested soft lease lifetime.
lease.grace_secondsExtra time before hard revocation.
lease.leased_atMonotonic timestamp when the lease was created.
lease.executorSafe executor proxy. It supports
submit()but rejects directshutdown()and submissions after release or revocation.lease.soft_expires_atMonotonic timestamp for soft expiry.
lease.hard_expires_atMonotonic timestamp for hard expiry.
await lease.run(fn, *args, **kwargs)Run a synchronous callable in the leased executor and await its result.
await lease.release()Return the lease. Calling it more than once is safe.
Async context manager¶
async with await manager.acquire(owner="job") as lease:
result = await lease.run(sync_function)