Web3.py: Tutorial: how to close providers? (warnings only, but still)

Created on 25 Oct 2017  路  4Comments  路  Source: ethereum/web3.py

  • Version: 3.1.6
  • Python: 3.5
  • OS: linux

What was wrong?

Using your web3py readthedocs providers.html I get warnings:

unclosed file and unclosed ssl.SSLSocket.

from web3 import Web3
from web3.providers.eth_tester import EthereumTesterProvider
from eth_tester import EthereumTester

web3tester = Web3(EthereumTesterProvider(EthereumTester()))
print ("EthereumTester bn:", web3tester.eth.blockNumber)

results in

.../env/epe-py3/lib/python3.5/site-packages/bitcoin/mnemonic.py:7: ResourceWarning: unclosed file <_io.TextIOWrapper name='.../env/epe-py3/lib/python3.5/site-packages/bitcoin/english.txt' mode='r' encoding='UTF-8'>
  wordlist_english=list(open(os.path.join(os.path.dirname(os.path.realpath(__file__)),'english.txt'),'r'))
EthereumTester bn: 0

and

from web3 import Web3, HTTPProvider
web3infura = Web3(HTTPProvider('https://ropsten.infura.io'))
print (web3infura.eth.blockNumber)

results in

Infura Ropsten: 1941234
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=3, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('192.168.2.231', 38734), raddr=('34.203.85.252', 443)>

How can it be fixed?

How to close a connection?

Most helpful comment

appears to be an issue with ... vbuterin/pybitcointools

thx @carver, I have raised an issue there.

sys:1: ResourceWarning: unclosed

This one looks like it could be fixed in web3, though.

Yes, please.

All 4 comments

.../env/epe-py3/lib/python3.5/site-packages/bitcoin/mnemonic.py:7: ResourceWarning: unclosed file ...

This appears to be an issue with https://github.com/vbuterin/pybitcointools

sys:1: ResourceWarning: unclosed <ssl.SSLSocket ...

This one looks like it could be fixed in web3, though.

appears to be an issue with ... vbuterin/pybitcointools

thx @carver, I have raised an issue there.

sys:1: ResourceWarning: unclosed

This one looks like it could be fixed in web3, though.

Yes, please.

[old issue cleanup]

Confirmed fixed.

Well done. Thanks. Cool: 1062 days ;-)

Was this page helpful?
0 / 5 - 0 ratings