From 78e2db18634cd8d6337ae0ed567bf0d6f5e12eb1 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 7 Mar 2016 17:54:51 -0500 Subject: [PATCH] Add support for aiohttp connectors. Fixes #98. --- discord/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/discord/client.py b/discord/client.py index d4207ab6b..d1a6f00ab 100644 --- a/discord/client.py +++ b/discord/client.py @@ -67,6 +67,8 @@ class Client: .. _deque: https://docs.python.org/3.4/library/collections.html#collections.deque .. _event loop: https://docs.python.org/3/library/asyncio-eventloops.html + .. _connector: http://aiohttp.readthedocs.org/en/stable/client_reference.html#connectors + .. _ProxyConnector: http://aiohttp.readthedocs.org/en/stable/client_reference.html#proxyconnector Parameters ---------- @@ -81,6 +83,9 @@ class Client: Indicates if :meth:`login` should cache the authentication tokens. Defaults to ``True``. The method in which the cache is written is done by writing to disk to a temporary directory. + connector : aiohttp.BaseConnector + The `connector`_ to use for connection pooling. Useful for proxies, e.g. + with a `ProxyConnector`_. Attributes ----------- @@ -132,7 +137,8 @@ class Client: 'user-agent': user_agent.format(library_version, sys.version_info, aiohttp.__version__) } - self.session = aiohttp.ClientSession(loop=self.loop) + connector = options.pop('connector', None) + self.session = aiohttp.ClientSession(loop=self.loop, connector=connector) self._closed = asyncio.Event(loop=self.loop) self._is_logged_in = asyncio.Event(loop=self.loop)