Documentation for eth_defi.event_reader.web3factory.TunedWeb3Factory Python class.

class TunedWeb3Factory[source]

Create 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

Methods summary

__init__(rpc_config_line[, http_adapter, ...])

Set up a factory.


Sum API call counts across all threads

__init__(rpc_config_line, http_adapter=None, thread_local_cache=False, api_counter=False)[source]

Set up a factory.

  • rpc_config_line (str) –

    JSON-RPC config line.

    See eth_defi.provider.multi_provider.

  • 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


Sum API call counts across all threads

Return type