Session
This page contains the API documentation for the gradual.runners.session module.
gradual.runners.session
The session module provides the HTTPSession class which extends the requests.Session class to provide connection pooling and reuse for HTTP requests during stress testing.
Classes
HTTPSession(pool_connections, pool_maxsize, *args, **kwargs)
Bases: Session
Custom HTTP session class with connection pooling capabilities.
This class extends requests.Session to provide efficient connection pooling for HTTP requests. It configures the underlying HTTPAdapter with specified pool sizes for both HTTP and HTTPS connections.
Attributes:
| Name | Type | Description |
|---|---|---|
adapter |
HTTPAdapter
|
The configured HTTP adapter with connection pooling |
Initialize the HTTP session with connection pooling configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pool_connections
|
int
|
Number of connection pools to maintain |
required |
pool_maxsize
|
int
|
Maximum number of connections per pool |
required |
*args
|
Additional positional arguments for Session initialization |
()
|
|
**kwargs
|
Additional keyword arguments for Session initialization |
{}
|
Source code in src/gradual/runners/session.py
Attributes
adapter = HTTPAdapter(pool_connections=pool_connections, pool_maxsize=pool_maxsize)
instance-attribute
Functions
close()
Close the HTTP session and its connection pools.
This method ensures proper cleanup of all connection pools and resources associated with this session.