From a38fb03121dfa29173f7b7531387de274a77affe Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:19:56 -0400 Subject: [PATCH] feat: CONTRACT_THREADS env (#786) * feat: CONTRACT_THREADS env * chore: `black .` * Update contracts.py --------- Co-authored-by: github-actions[bot] --- y/ENVIRONMENT_VARIABLES.py | 9 +++++++++ y/contracts.py | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/y/ENVIRONMENT_VARIABLES.py b/y/ENVIRONMENT_VARIABLES.py index 53d0b5728..d028be63a 100644 --- a/y/ENVIRONMENT_VARIABLES.py +++ b/y/ENVIRONMENT_VARIABLES.py @@ -10,6 +10,15 @@ ) """TTL for contract cache, defaults to :obj:`CACHE_TTL` if not set""" +CONTRACT_THREADS = _envs.create_env( + "CONTRACT_THREADS", + PruningThreadPoolExecutor, + default=10, + string_converter=int, + verbose=False, +) +"""The number of threads to use to fetch contract abis""" + GETLOGS_BATCH_SIZE = _envs.create_env("GETLOGS_BATCH_SIZE", int, default=0) """Batch size for getlogs operations, 0 will use default as determined by your provider.""" diff --git a/y/contracts.py b/y/contracts.py index cf027277d..5edeefa8d 100644 --- a/y/contracts.py +++ b/y/contracts.py @@ -49,8 +49,6 @@ logger = logging.getLogger(__name__) -contract_threads = a_sync.PruningThreadPoolExecutor(16) - _brownie_deployments_db_lock = threading.Lock() # These tokens have trouble when resolving the implementation via the chain. @@ -473,7 +471,7 @@ async def _coroutine( Returns: A Contract instance for the given address. """ - contract = await contract_threads.run( + contract = await ENVS.CONTRACT_THREADS.run( cls, address, require_success=require_success )