Requestor

The Requestor is the lowest-level component in asyncprawcore. It wraps an aiohttp.ClientSession and is responsible for issuing the actual HTTP requests to Reddit. Subclass it to customize request behavior, for example to add caching or logging.

class asyncprawcore.requestor.Requestor(user_agent, oauth_url='https://oauth.reddit.com', reddit_url='https://www.reddit.com', session=None, loop=None, timeout=16.0)

Requestor provides an interface to HTTP requests.

Parameters:
async close()

Call close on the underlying session.

Return type:

None

request(*args, timeout=None, **kwargs)

Issue the HTTP request capturing any errors that may occur.

Parameters:
  • args (Any) – Positional arguments to pass to aiohttp.ClientSession.request.

  • timeout (float | None) – How many seconds to wait for the server to send data before giving up (default: None).

  • kwargs (Any) – Keyword arguments to pass to aiohttp.ClientSession.request.

Return type:

AsyncGenerator[ClientResponse]

Returns:

The response from the request.

Raises:

RequestException: If an error occurs while issuing the request.