event_reader.web3factory
Documentation for eth_defi.event_reader.web3factory Python module.
Web3 connection factory.
Methods for creating Web3 connections over multiple threads and processes.
Classes
Single reusable Web3 connection. |
|
Create a Web3 connections. |
|
Create a new Web3 connection. |
- class Web3Factory
Bases:
ProtocolCreate a new Web3 connection.
Web3 connection cannot be passed across thread/process boundaries
Help to setup TCP/IP connections and Web3 instance over it in threads and processes
When each worker is initialised, the factory is called to get JSON-RPC connection
See Python documentation regarding typing.Protocol.
- __init__(*args, **kwargs)
- class TunedWeb3Factory
Bases:
eth_defi.event_reader.web3factory.Web3FactoryCreate a Web3 connections.
A factory that allows us to pass web3 connection creation method across thread and process bounderies.
Disable AttributedDict middleware and other middleware that slows us down
Enable graceful retries in the case of network errors and API throttling
Use faster ujson instead of stdlib json to decode the responses
Set up a factory.
- Parameters
rpc_config_line –
JSON-RPC config line.
http_adapter –
Connection pooling for HTTPS.
Parameters for requests library. Default to pool size 10.
thread_local_cache –
Construct the web3 connection only once per thread.
If you are using thread pooling, recycles the connection across different factory calls.
api_counter – Enable API counters
- __init__(rpc_config_line, http_adapter=None, thread_local_cache=False, api_counter=False)
Set up a factory.
- Parameters
rpc_config_line (str) –
JSON-RPC config line.
http_adapter (Optional[requests.adapters.HTTPAdapter]) –
Connection pooling for HTTPS.
Parameters for requests library. Default to pool size 10.
thread_local_cache –
Construct the web3 connection only once per thread.
If you are using thread pooling, recycles the connection across different factory calls.
api_counter – Enable API counters
- get_total_api_call_counts()
Sum API call counts across all threads
- Return type