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
When you create a client with client.ClientSession(timeout=500) does not raise or warn that timeout must be implemented as ClientTimeout but fails when sending a get request
Code lets you implement a client as client.ClientSession(timeout='bad_arg')
To Reproduce
Implement a client with timeout of type int or float and send a get request
import asyncio
import aiohttp
async def main():
# No issues creating a client session
aiohttp_client = aiohttp.ClientSession(timeout=100)
try:
# Fails sending GET request
await aiohttp_client.get("https://example.com", )
finally:
# Close client session
await aiohttp_client.close()
asyncio.run(main())
A ValueError has to be raised when using something other than ClientTimeout or None.
Logs/tracebacks
Traceback (most recent call last):
File "/Users/voltaic/workspace/parsing_excersizes/async_requests/main.py", line 15, in <module>
asyncio.run(main())
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in runreturn runner.run(main)
^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in runreturnself._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 684, in run_until_completereturn future.result()
^^^^^^^^^^^^^^^
File "/Users/voltaic/workspace/parsing_excersizes/async_requests/main.py", line 10, in mainawait aiohttp_client.get("https://example.com", )
File "/Users/voltaic/Library/Application Support/hatch/env/virtual/async-requests/3bENKOFX/async-requests/lib/python3.12/site-packages/aiohttp/client.py", line 470, in _requestself._loop, real_timeout.total, ceil_threshold=real_timeout.ceil_threshold
^^^^^^^^^^^^^^^^^^AttributeError: 'int' object has no attribute 'total'
Describe the bug
When you create a client with
client.ClientSession(timeout=500)
does not raise or warn that timeout must be implemented asClientTimeout
but fails when sending a get requestCode lets you implement a client as
client.ClientSession(timeout='bad_arg')
To Reproduce
int
orfloat
and send a get requeststr
typeExpected behavior
A
ValueError
has to be raised when using something other thanClientTimeout
orNone
.Logs/tracebacks
Python Version
Python 3.12.1
aiohttp Version
multidict Version
yarl Version
OS
macOS, Linux
Related component
Client
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: