You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Running Python 3.10, making any call to S3 without immediately closing the S3 client will cause the following warning to be emitted.
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py:320: ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x10814dcc0>
_warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
Here is a minimally reproducible example:
importasyncioimportaiobotocoreimportwarningsimportaiobotocore.sessionwarnings.simplefilter("default") # Warning only goes to console if this call is madeasyncdefmain():
session=aiobotocore.session.get_session(
# Replace with real tokens
{
"AWS_ACCESS_KEY_ID": "test",
"AWS_SECRET_ACCESS_KEY": "test",
"AWS_SESSION_TOKEN": "test",
}
)
asyncwithsession.create_client('s3') ass3:
print("Entered client")
try:
awaits3.get_object(Bucket='bucket', Key="key")
exceptExceptionasexc:
print("Execption", exc)
# On Python 3.10, a ResourceWarning will appear during the sleep. If instead the client is# closed immediately after the get_object() call is made, the warning will not appear.# However, this is not desirable, as we want to share the client across multiple coroutines.awaitasyncio.sleep(10)
print("Exited client")
awaitasyncio.sleep(10)
if__name__=="__main__":
asyncio.run(main())
Running this outputs the following:
Entered client
Execption An error occurred (AccessDenied) when calling the GetObject operation: Access Denied
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py:320: ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x104d2dcc0>
_warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
Exited client
Commenting out the first sleep, the warning disappears:
Entered client
Execption An error occurred (AccessDenied) when calling the GetObject operation: Access Denied
Exited client
Checklist
I have reproduced in environment where pip check passes without errors
I have provided pip freeze results
I have provided sample code or detailed way to reproduce
I have tried the same code in botocore to ensure this is an aiobotocore specific issue
I have tried similar code in aiohttp to ensure this is is an aiobotocore specific issue
I have checked the latest and older versions of aiobotocore/aiohttp/python to see if this is a regression / injection
Running the code on Python 3.11 with the exact same dependencies will fix the issue.
I've tried similar code in botocore and the issue doesn't occur. Though the code isn't exactly equivalent since clients are not context managers in botocore
I've tried leaving long running sessions in aiohttp and the issue doesn't occur either.
I see the same behavior going all the way back into aiobotocore==1.4.0 and aiohttp==3.7.0. Any earlier versions and I start to see other errors that prevents the code from running.
The text was updated successfully, but these errors were encountered:
larashores
changed the title
Unclosed transport error with long running client under Python 3.10
"unclosed transport" warning with long running client under Python 3.10
Oct 3, 2024
Describe the bug
Running Python 3.10, making any call to S3 without immediately closing the S3 client will cause the following warning to be emitted.
Here is a minimally reproducible example:
Running this outputs the following:
Commenting out the first sleep, the warning disappears:
Checklist
pip check
passes without errorspip freeze
resultspip freeze results
Environment:
Additional context
botocore
and the issue doesn't occur. Though the code isn't exactly equivalent since clients are not context managers inbotocore
aiohttp
and the issue doesn't occur either.aiobotocore==1.4.0
andaiohttp==3.7.0
. Any earlier versions and I start to see other errors that prevents the code from running.The text was updated successfully, but these errors were encountered: