Skip to content

Unclosed client session + Unclosed connector warnings #3524

@quetz

Description

@quetz

What happened?

Creating two AsyncWeb3 instances results in warnings on app exit.

Code that produced the error

#!python3

import asyncio
from web3 import AsyncWeb3, HTTPProvider
from web3.providers import AsyncHTTPProvider

async def main():
    rpc = "https://mainnet.optimism.io"
    w3_1 = AsyncWeb3(AsyncHTTPProvider(rpc))
    await w3_1.eth.block_number
    w3_2 = AsyncWeb3(AsyncHTTPProvider(rpc))
    await w3_2.eth.block_number

asyncio.run(main())

Full error output

Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x103fc0ad0>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x103f5f9b0>, 8352140.600221)]']
connector: <aiohttp.connector.TCPConnector object at 0x103fc0c20>

Fill this section in if you know how this could or should be fixed

No response

web3 Version

7.4.0

Python Version

3.13.0

Operating System

osx

Output from pip freeze

aiohappyeyeballs==2.4.3
aiohttp==3.10.10
aiosignal==1.3.1
annotated-types==0.7.0
asttokens==2.4.1
attrs==24.2.0
bitarray==3.0.0
certifi==2024.8.30
charset-normalizer==3.4.0
ckzg==2.0.1
cytoolz==1.0.0
decorator==5.1.1
eth-account==0.13.4
eth-hash==0.7.0
eth-keyfile==0.8.1
eth-keys==0.6.0
eth-rlp==2.1.0
eth-typing==5.0.1
eth-utils==5.1.0
eth_abi==5.1.0
executing==2.1.0
frozenlist==1.5.0
hexbytes==1.2.1
idna==3.10
ipython==8.28.0
jedi==0.19.1
matplotlib-inline==0.1.7
multidict==6.1.0
parsimonious==0.10.0
parso==0.8.4
pexpect==4.9.0
prompt_toolkit==3.0.48
propcache==0.2.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycryptodome==3.21.0
pydantic==2.9.2
pydantic_core==2.23.4
Pygments==2.18.0
pyunormalize==16.0.0
regex==2024.9.11
requests==2.32.3
rlp==4.0.1
six==1.16.0
stack-data==0.6.3
toolz==1.0.0
traitlets==5.14.3
types-requests==2.32.0.20241016
typing_extensions==4.12.2
urllib3==2.2.3
wcwidth==0.2.13
web3==7.4.0
websockets==13.1
wheel @ file:///opt/homebrew/Cellar/python%403.13/3.13.0_1/libexec/wheel-0.44.0-py3-none-any.whl#sha256=f49b82715dce6365f75eddcb0a9bb47d0d46feaf14bbc739dfcbd677b7073f5b
yarl==1.17.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions