High-level gRPC channel manager for the Nebius Python SDK.
Channel locks follow one order. Code can acquire _channel_pool_lock before _tasks_lock or a runtime lock, and _close_submit_lock before a runtime lock. It must not acquire these locks in reverse order. No code awaits, joins a thread, or waits for a future while it holds a channel lock. SDK task objects are copied under their lock and then cancelled or awaited after the lock is released.
| Class | |
Manage high-level gRPC channels for the SDK. |
| Class | |
A small callable wrapper that binds RPC calls to a Channel-managed address. |
| Class | |
Marker type used to explicitly disable authorization. |
| Exception | |
Raised when an operation is attempted on a closed Channel. |
| Exception | |
Exception raised when a synchronous helper conflicts with an asyncio event loop. |
| Function | set |
Set or override the grpc.primary_user_agent channel option. |
| Constant | P |
Undocumented |
| Type Variable | C |
Undocumented |
| Type Variable | |
Undocumented |
| Type Variable | |
Undocumented |
| Type Variable | T |
Undocumented |
| Variable | |
Undocumented |
| Variable | logger |
Undocumented |
| Class | _ |
Provide cross-loop access to one unary gRPC call. |
| Class | _ |
Run one authorization authenticator on the SDK event loop. |
| Class | _ |
Run an authorization provider on the SDK event loop. |
| Class | _ |
Resolve and retain one operation-service address on the SDK loop. |
| Function | _finalize |
Shut down a runtime only in the process that created it. |
| Function | _get |
Return the loop that a newly created gRPC AsyncIO channel will use. |
| Function | _monitor |
Release close reservations when their owner loops stop. |
| Function | _reset |
Drop parent-process task and lock state in a forked child. |
| Function | _retain |
Retain foreign-loop cleanup without retaining its parent channel. |
| Function | _schedule |
Create detached close work only after its owner loop executes. |
| Function | _shutdown |
Stop a partially constructed channel's runtime before re-raising. |
| Function | _start |
Start and retain detached close work on the current owner loop. |
| Function | _watch |
Use one daemon monitor for all close callbacks on stopped loops. |
| Constant | _DETACHED |
Undocumented |
| Variable | _detached |
Undocumented |
| Variable | _detached |
Undocumented |
| Variable | _transport |
Undocumented |
| Variable | _transport |
Undocumented |
| Variable | _transport |
Undocumented |
| Variable | _transport |
Undocumented |
str, options: ChannelArgumentType | None) -> ChannelArgumentType:
(source)
¶
Set or override the grpc.primary_user_agent channel option.
This helper appends the provided user-agent string to the options sequence, which is passed to gRPC when creating channels. If the grpc.primary_user_agent option is already present in options, it will be replaced with the new value.
| Parameters | |
| user | The user-agent string to set. |
| options:optional list of (str, Any) tuples | Existing channel options, if any. |
| Returns | |
| list of (str, Any) tuples | The updated channel options including the user-agent. |
Shut down a runtime only in the process that created it.
Threads and locks do not survive fork coherently. A child finalizer must therefore avoid touching inherited runtime state.
| Parameters | |
runtime:AsyncRuntime | Runtime owned by the finalized channel. |
processint | Process that created runtime. |
Drop parent-process task and lock state in a forked child.
Event-loop tasks cannot be transferred across fork. Replacing both objects also prevents a child from observing a lock held by a vanished parent thread.
Retain foreign-loop cleanup without retaining its parent channel.
A caller-owned event loop keeps only weak references to tasks. A cross-thread dispatch returns a concurrent Future. The SDK retains either handle until completion. A callback in the owner loop's public scheduling queue retains the handle. It renews a long timer while the close is pending. The module-level weak set is only for diagnostics and tests. As a result, the retention cycle has no process-global strong reference. If the application drops a stopped loop, its pending close state can be collected with it. This design does not add private attributes to the loop, so it also supports fixed-slot loop types.
The registry contains only detached cleanup. It does not contain per-SDK scheduler or bridge state. Its lock lets independent SDK instances and owner-loop threads use it at the same time.
| Parameters | |
handle:Any | Foreign-loop transport-close task or Future to retain. |
ownerAbstractEventLoop | Event loop that owns the close operation. |
Callable[ [], Coroutine[ Any, Any, None]], owner_loop: AbstractEventLoop, name: str, completion: ConcurrentFuture[ None] | None = None) -> bool:
(source)
¶
Create detached close work only after its owner loop executes.
A loop can accept a thread-safe callback and stop before it executes that callback. The callback retains the factory instead of a coroutine, so loop closure cannot discard unawaited close work. The detached task settles an optional SDK reservation after it starts or rejects the close work.
| Parameters | |
factory:Callable[ | Function that creates close work on the owner loop. |
ownerAbstractEventLoop | Event loop that owns the close work. |
name:str | Diagnostic task name. |
completion:ConcurrentFuture[ | Optional SDK lifecycle reservation. |
| Returns | |
bool | True if the loop accepted or started the close work. |
Callable[ Concatenate[ C, P], None]) -> Callable[ Concatenate[ C, P], None]:
(source)
¶
Stop a partially constructed channel's runtime before re-raising.
A constructor traceback can retain the incomplete channel, so its weakref finalizer is not a timely resource boundary. This wrapper starts cleanup for every exception after runtime creation without obscuring the public signature or documentation. It waits for an owned runtime. It only schedules cleanup on a running caller-owned loop, because waiting for an unresponsive borrowed loop would prevent the constructor from propagating an interruption.
| Parameters | |
initializer:Callable[ | Channel initializer to guard. |
| Returns | |
Callable[ | Initializer that stops an acquired runtime on failure. |
Coroutine[ Any, Any, None], owner_loop: AbstractEventLoop, name: str, completion: ConcurrentFuture[ None] | None = None) -> bool:
(source)
¶
Start and retain detached close work on the current owner loop.
A custom task factory can reject task creation. This helper closes the rejected coroutine and settles an optional SDK lifecycle reservation, so the rejection cannot strand shutdown.
| Parameters | |
closeCoroutine[ | Transport-close coroutine to start. |
ownerAbstractEventLoop | Running loop that owns close_coro. |
name:str | Diagnostic task name. |
completion:ConcurrentFuture[ | Optional SDK lifecycle reservation to settle on failure. |
| Returns | |
bool | True if task creation succeeded. |
AbstractEventLoop, completion: ConcurrentFuture[ None]):
(source)
¶
Use one daemon monitor for all close callbacks on stopped loops.
| Parameters | |
ownerAbstractEventLoop | Loop that accepted the close callback. |
completion:ConcurrentFuture[ | SDK lifecycle reservation to release if the loop stops. |
list[ tuple[ Callable[ [], AbstractEventLoop | None], ConcurrentFuture[ None]]] =
(source)
¶
Undocumented