Skip to content

Commit

Permalink
feat: CONTRACT_THREADS env (#786)
Browse files Browse the repository at this point in the history
* feat: CONTRACT_THREADS env

* chore: `black .`

* Update contracts.py

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
BobTheBuidler and github-actions[bot] authored Nov 25, 2024
1 parent a63918c commit a38fb03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 9 additions & 0 deletions y/ENVIRONMENT_VARIABLES.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
4 changes: 1 addition & 3 deletions y/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
)

Expand Down

0 comments on commit a38fb03

Please sign in to comment.