-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: {'code': -32700, 'message': 'parse error'} and Can't pickle local object 'construct_web3_formatting_middleware' #3341
Comments
Update: I figured out that if I don't declare
and if I declare
Maybe there is any way to close connection |
Update: this solution works, but it's ugly option. Creating new testnet = 'http://127.0.0.1:8545/'
def calculate_transaction(i):
w3 = Web3(Web3.HTTPProvider(testnet + f'?{i}')) |
On first glance, it looks like something to do with how we generate the cache key and multiprocessing. I'm glad you found a workaround though. We'll put this in our queue to look into. Thanks for the issue! |
@fridary when I run your example, I do error out but with the following message:
When I do run with the from web3 import Web3
from multiprocessing import Pool, cpu_count
w3 = Web3(Web3.HTTPProvider(HTTP_LOCAL))
def calculate_transaction(i, hash_):
global w3
# gives error
transaction = w3.eth.get_transaction(hash_)
print(i, transaction['hash'].hex())
def main():
global w3
if not w3.is_connected():
exit("w3 not connected")
block = w3.eth.get_block('latest')
transactions = block['transactions'][:min(cpu_count(), 50)]
params = []
for i, hash_ in enumerate(transactions):
params.append((i, hash_))
pool = Pool(min(cpu_count(), 50))
pool.starmap_async(calculate_transaction, params).get()
pool.close()
if __name__ == "__main__":
main() I'm going to close this as I can't reproduce it. If that does not resolve the issue and you see that something else is going on, please reach back out to re-open. If it helps, my |
What happened?
Erigon: 2.59.3-088fd8ef (last March 2024)
I have a problem to parallel querying local Erigon node. By the end of execution there is an error
ValueError: {'code': -32700, 'message': 'parse error'}
.Error is always returned on last request, whether I query 4 or 50 transactions in
Pool
.Although, if I test code on public node (
https://eth-pokt.nodies.app
in example) instead of'http://127.0.0.1:8545'
, problem is gone.Yes, perhaps problem is in Erigon. But if I do
requests.post()
, there is no error.If I do another query like
w3.eth.get_block(block)
, error is the same.Any ideas what's wrong?
Update: it seems problem is in declaring
w3
outside pool process together with inside (calculate_transaction()
) for local nodes.Erigon:
/home/fridary/erigon/build/bin/erigon --internalcl --datadir=/disk_sde/erigon --http.api=eth,erigon,engine,web3,net,debug,trace,txpool --authrpc.jwtsecret=/home/fridary/erigon/jwtsecret --metrics --prune.h.before=13916166 --prune.r.before=13916166 --prune.t.before=13916166 --prune.c.before=13916166 --torrent.download.rate=128mb
Code that produced the error
Full error output
The text was updated successfully, but these errors were encountered: