reqivo.transport packageΒΆ

SubmodulesΒΆ

reqivo.transport.connection moduleΒΆ

src/reqivo/transport/connection.py

TCP and TLS connection management module.

This module provides low-level connection handling with support for TLS encryption, proxy connections, and proper error handling for network operations.

class reqivo.transport.connection.Connection(host: str, port: int, use_ssl: bool = False, timeout: float | Timeout | None = None)[source]ΒΆ

Bases: object

Manages TCP and TLS connection creation and lifecycle.

hostΒΆ

The target hostname or IP address.

portΒΆ

The target port number.

use_sslΒΆ

Whether to use TLS encryption.

timeoutΒΆ

Connection timeout configuration.

sockΒΆ

The underlying socket object.

open() socket[source]ΒΆ

Open TCP connection with optional TLS encryption.

close() None[source]ΒΆ

Close the connection if it is open.

is_usable() bool[source]ΒΆ

Check if the connection appears usable (not closed by peer).

class reqivo.transport.connection.AsyncConnection(host: str, port: int, use_ssl: bool = False, timeout: float | Timeout | None = None)[source]ΒΆ

Bases: object

Manages asynchronous TCP and TLS connection creation and lifecycle.

async open() None[source]ΒΆ

Async open.

is_usable() bool[source]ΒΆ

Check if connection is usable.

async close() None[source]ΒΆ

Async close.

reqivo.transport.connection_pool moduleΒΆ

src/reqivo/transport/connection_pool.py

Connection pooling module.

This module provides connection pool management for efficient reuse of TCP/TLS connections across multiple HTTP requests.

class reqivo.transport.connection_pool.ConnectionPool(max_size: int = 10, max_idle_time: float = 30.0)[source]ΒΆ

Bases: object

Pool of reusable open connections.

Maintains a cache of open connections keyed by (host, port, ssl, proxy) to enable connection reuse across multiple requests.

This implementation is thread-safe and supports multiple connections per host.

get_connection(host: str, port: int, use_ssl: bool, timeout: float | Timeout | None = None) Connection[source]ΒΆ

Get an existing connection or create a new one. Blocks if max_size is reached until a connection is available.

put_connection(conn: Connection) None[source]ΒΆ

Return a connection to the pool with timestamp.

discard_connection(conn: Connection) None[source]ΒΆ

Discard a connection and release its slot.

release_connection(host: str, port: int, use_ssl: bool) None[source]ΒΆ

Deprecated: Manual release by key.

close_all() None[source]ΒΆ

Close all connections in the pool.

class reqivo.transport.connection_pool.AsyncConnectionPool(max_size: int = 10, max_idle_time: float = 30.0)[source]ΒΆ

Bases: object

Pool of reusable asynchronous connections.

async get_connection(host: str, port: int, use_ssl: bool, timeout: float | Timeout | None = None) AsyncConnection[source]ΒΆ

Returns an existing connection or creates a new one.

async put_connection(conn: AsyncConnection) None[source]ΒΆ

Returns a connection to the pool for reuse with timestamp.

async discard_connection(conn: AsyncConnection) None[source]ΒΆ

Discard async connection and release slot.

async release_connection(host: str, port: int, use_ssl: bool) None[source]ΒΆ

Closes and removes all connections for the key.

async close_all() None[source]ΒΆ

Closes all connections in the pool.

reqivo.transport.selectors moduleΒΆ

src/reqivo/transport/selectors.py

Helpers for networking selectors and async/non-blocking operations.

reqivo.transport.tls moduleΒΆ

src/reqivo/transport/tls.py

Advanced TLS configuration for Reqivo.

reqivo.transport.tls.create_ssl_context() SSLContext[source]ΒΆ

Creates a default SSL context with TLS 1.2 minimum.