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

Specify timeout in aiohttp.request #3213

Merged
merged 3 commits into from
Aug 31, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@ Jashandeep Sohi
Jeongkyu Shin
Jeroen van der Heijden
Jesus Cea
Jian Zeng
Jinkyu Yi
Joel Watts
Jon Nabozny
5 changes: 4 additions & 1 deletion aiohttp/client.py
Original file line number Diff line number Diff line change
@@ -906,6 +906,7 @@ def request(method, url, *,
connector=None,
loop=None,
read_until_eof=True,
timeout=sentinel,
proxy=None,
proxy_auth=None) -> _SessionRequestContextManager:
"""Constructs and sends a request. Returns response object.
@@ -933,6 +934,8 @@ def request(method, url, *,
read_until_eof - Read response until eof if response
does not have Content-Length header.
loop - Optional event loop.
timeout - Optional ClientTimeout settings structure, 5min
total timeout by default.
Usage::
>>> import aiohttp
>>> resp = await aiohttp.request('GET', 'http://python.org/')
@@ -946,7 +949,7 @@ def request(method, url, *,
connector = TCPConnector(loop=loop, force_close=True)

session = ClientSession(
loop=loop, cookies=cookies, version=version,
loop=loop, cookies=cookies, version=version, timeout=timeout,
connector=connector, connector_owner=connector_owner)

return _SessionRequestContextManager(
5 changes: 4 additions & 1 deletion docs/client_reference.rst
Original file line number Diff line number Diff line change
@@ -660,7 +660,7 @@ certification chaining.
version=HttpVersion(major=1, minor=1), \
compress=None, chunked=None, expect100=False, raise_for_status=None, \
connector=None, loop=None,\
read_until_eof=True)
read_until_eof=True, timeout=sentinel)

:async-with:

@@ -719,6 +719,9 @@ certification chaining.
does not have Content-Length header.
``True`` by default (optional).

:param timeout: a :class:`ClientTimeout` settings structure, 5min
total timeout by default.

:param loop: :ref:`event loop<asyncio-event-loop>`
used for processing HTTP requests.
If param is ``None``, :func:`asyncio.get_event_loop`