banteg / multicall.py

aggregate results of multiple smart contract calls into one
MIT License
251 stars 108 forks source link

Error with ThreadPool 'Timeout context manager should be used inside a task' #77

Open 0rtis opened 1 year ago

0rtis commented 1 year ago

Using Multicall more than once in a thread throw an error Timeout context manager should be used inside a task. This error was previously reported here #41 and was fixed there #51 However, I am facing this error while using Multicall in a ThreadPool:

tp = ThreadPool(processes=1)
tp.apply_async(func=execute, args=(task, ))

def execute(task):
    w3 = Web3(Web3.HTTPProvider('http://rpc.url'))
    for v in Multicall(self.calls, _w3=w3)().values():
        print(v)

I am using multicall 0.7.2 and web3 6.4.0 Same results using web3 5.31.3 as recommend in issue #41