From 61a8308a0a6822462d0847c9597ca5106aa7ea58 Mon Sep 17 00:00:00 2001 From: SharpBit <31069084+SharpBit@users.noreply.github.com> Date: Sun, 10 Mar 2019 11:25:01 -0400 Subject: [PATCH 1/2] optional connector --- brawlstats/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/brawlstats/core.py b/brawlstats/core.py index b19813f..0b70da1 100644 --- a/brawlstats/core.py +++ b/brawlstats/core.py @@ -46,7 +46,10 @@ class Client: def __init__(self, token, session=None, timeout=10, is_async=False, **options): self.is_async = is_async self.loop = options.get('loop', asyncio.get_event_loop()) - self.session = session or (aiohttp.ClientSession(loop=self.loop) if self.is_async else requests.Session()) + self.connector = options.get('connector') + self.session = session or ( + aiohttp.ClientSession(loop=self.loop, connector=self.connector) if self.is_async else requests.Session() + ) self.timeout = timeout self.api = API(options.get('base_url')) self.debug = options.get('debug', False) From e43fa372352f2fbd9d06ea4849a4c9262a675fee Mon Sep 17 00:00:00 2001 From: SharpBit <31069084+SharpBit@users.noreply.github.com> Date: Sun, 10 Mar 2019 11:36:36 -0400 Subject: [PATCH 2/2] document the working fix for OSError --- brawlstats/core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/brawlstats/core.py b/brawlstats/core.py index 0b70da1..3df59ae 100644 --- a/brawlstats/core.py +++ b/brawlstats/core.py @@ -35,6 +35,9 @@ class Client: The ``event loop`` to use for asynchronous operations. Defaults to ``None``, in which case the default event loop is used via ``asyncio.get_event_loop()``. If you are passing in an aiohttp session, using this will not work. You must set it when initializing the session. + connector: Optional[aiohttp.TCPConnector] + Pass in a TCPConnector for the client. Defaults to ``None``, + If you are passing in an aiohttp session, using this will not work. You must set it when initializing the session. debug: Optional[bool] = False Whether or not to give you more info to debug easily. base_url: Optional[str] = None