GitHub

API reference for rc_ref.

RcRef[A, E]: a resource acquired on first use and shared while in use.

get acquires the resource the first time (or joins an acquisition in progress) and holds a reference until the caller's Scope closes. The last reference to go releases the resource, at once or after idle_time_to_live; the next get acquires afresh. Closing the scope that made the ref releases the resource and interrupts a pending acquisition; a get after that is interrupted.

The acquisition runs on a fiber of its own, so callers can leave without killing it while others still wait; it is interrupted once every waiting caller has left.

AttributeTypeDescription
A_co= TypeVar('A_co', covariant=True)
E_co= TypeVar('E_co', covariant=True, default=Never)

Classes