Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clientsession timeout property #4193

Merged
merged 2 commits into from Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/4191.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added `ClientSession.timeout` property.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ Stepan Pletnev
Stephen Granade
Steven Seguin
Sunghyun Hwang
Sunit Deshpande
Sviatoslav Bulbakha
Sviatoslav Sydorenko
Taha Jahangir
Expand Down
5 changes: 5 additions & 0 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,11 @@ def requote_redirect_url(self) -> bool:
"""Do URL requoting on redirection handling."""
return self._requote_redirect_url

@property
def timeout(self) -> Union[object, ClientTimeout]:
"""Timeout for the session."""
return self._timeout

def detach(self) -> None:
"""Detach connector from session without closing the former.

Expand Down
7 changes: 5 additions & 2 deletions tests/test_client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,13 @@ async def test_client_session_custom_attr() -> None:
session.custom = None


async def test_client_session_timeout_args(loop) -> None:
async def test_client_session_timeout_default_args(loop) -> None:
session1 = ClientSession()
assert session1._timeout == client.DEFAULT_TIMEOUT
assert session1.timeout == client.DEFAULT_TIMEOUT

async def test_client_session_timeout_argument() -> None:
session = ClientSession(timeout=500)
assert session.timeout == 500

async def test_requote_redirect_url_default() -> None:
session = ClientSession()
Expand Down