Skip to content

miniproto.connection.sender.MTProtoSender.request

miniproto.connection.sender.MTProtoSender.request

Section titled “miniproto.connection.sender.MTProtoSender.request”
request(body: bytes | object, *, content_related: bool = True, retry_safe: bool = False, request_timeout: float | None = None, quick_ack: bool = False, quick_ack_callback: Callable[[QuickAckReceipt], None] | None = None) -> object

Send one RPC and await its decoded result with safe retry controls.

Parameters:

  • body (bytes | object) – Encoded MTProto bytes or a serializable TL request object.
  • content_related (bool) – Allocate a content-related sequence number; defaults to True.
  • retry_safe (bool) – Permit automatic resend with a fresh message ID after a transport loss; defaults to False to avoid duplicating unknown-side-effect RPCs.
  • request_timeout (float | None) – Optional caller wait bound in seconds. None waits until a result, lifecycle failure, or cancellation.
  • quick_ack (bool) – Request a transport quick ACK for the encrypted attempt; defaults to False and never completes this RPC by itself.
  • quick_ack_callback (Callable[[QuickAckReceipt], None] | None) – Optional synchronous callback receiving the first non-stale :class:QuickAckReceipt; supplying it also requests an ACK. Callback failures are isolated and recorded.

Returns:

  • object – The decoded RpcResult.result or a service response such as
  • object – class:Pong.

Raises:

  • PendingRpcLimitExceeded – If max_pending_rpcs capacity is full.
  • TimeoutError – If request_timeout expires; its pending aliases and quick-ACK registrations are removed.
  • AmbiguousRpcResult – If an unsafe request loses transport after it may have reached Telegram.
  • TransportError – If connection/recovery exhausts or protocol handling fails.
  • CancelledError – If the caller cancels; its pending state is removed without cancelling other requests.
Notes

Calls may run concurrently. Sending and message ID allocation are serialized internally, while futures resolve independently.