hikari.internal.net#

General bits and pieces that are reused between components.

Module Contents#

hikari.internal.net.create_client_session(connector, connector_owner, http_settings, raise_for_status, trust_env)[source]#

Generate a client session using the given settings.

Warning

You must invoke this from within a running event loop.

Note

If you pass an explicit connector, then the connection that is created will not own the connector. You will be expected to manually close it __after__ the returned client session is closed to prevent leaking resources.

Parameters:
connectoraiohttp.BaseConnector

The connector to use.

connector_ownerbool

If True, then the client session will close the connector on shutdown. Otherwise, you must do it manually.

http_settingshikari.impl.config.HTTPSettings

HTTP settings to use.

raise_for_statusbool

True to default to throwing exceptions if a request fails, or False to default to not.

trust_envbool

True to trust anything in environment variables and the netrc file, False to ignore it.

Returns:
aiohttp.ClientSession

The client session to use.

async hikari.internal.net.generate_error_response(response)[source]#

Given an erroneous HTTP response, return a corresponding exception.