0

I am polling the Eth.getTransactionReceipt and the ContractFunction.call to get the transaction receipt for a mass transaction submitted onto the Ethereum chain. I notices that I have a lot of CLOSE_WAIT to occupied opened files.

My code as below:

Transaction:

tx_hash = contract_instance.functions.setApprovalForAll(
    Web3.toChecksumAddress(a['set_operation_to_this_account_address']), b['approval']
            ).transact({'from': self.w3.toChecksumAddress(a['original_account_address']), 'gas': int(gas_estimate)})

Call:

last_token = contract_instance.functions.getId().call()

Check the file handle occupied: >lsof -p 3146 |grep CLOSE

python3 20371 ubuntu  776u     IPv4             751767      0t0    TCP ubuntu:49060->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  777u     IPv4             716763      0t0    TCP ubuntu:41102->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  778u     IPv4             725121      0t0    TCP ubuntu:40790->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  779u     IPv4             631622      0t0    TCP ubuntu:35948->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  780u     IPv4             724478      0t0    TCP ubuntu:41798->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  781u     IPv4             752720      0t0    TCP ubuntu:49072->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  782u     IPv4             720853      0t0    TCP ubuntu:41484->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  783u     IPv4             722860      0t0    TCP ubuntu:41600->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  784u     IPv4             720880      0t0    TCP ubuntu:41640->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  786u     IPv4             632055      0t0    TCP ubuntu:35940->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  788u     IPv4             634447      0t0    TCP ubuntu:36712->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  789u     IPv4             749089      0t0    TCP ubuntu:49176->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu  814u     IPv4             723730      0t0    TCP ubuntu:41878->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu 1062u     IPv4             748998      0t0    TCP ubuntu:48724->192.168.54.154:https (CLOSE_WAIT)
python3 20371 ubuntu 1063u     IPv4             750865      0t0    TCP ubuntu:48952->192.168.54.154:https (CLOSE_WAIT)

Total count of CLOSE_WAIT: lsof -p 20371 |grep CLOSE |wc -l 682

How can I set a timeout for each transaction call that these connection will not occupy the file handle in long period?

Environment: Python 3.6.9 Web3 5.21.1 Geth 1.9.21

Maybe I would narrow down the issue by the setting of the middleware of the web3.py. How can I setup the timeout for each requests call in middleware layer in web3.py?

Anyone can help would be appreciated.

Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.