Add underscore to HTTPClient.session to imply privateness.
This commit is contained in:
parent
c4c17351c6
commit
76e76f2905
@ -90,7 +90,7 @@ class HTTPClient:
|
|||||||
def __init__(self, connector=None, *, loop=None):
|
def __init__(self, connector=None, *, loop=None):
|
||||||
self.loop = asyncio.get_event_loop() if loop is None else loop
|
self.loop = asyncio.get_event_loop() if loop is None else loop
|
||||||
self.connector = connector
|
self.connector = connector
|
||||||
self.session = aiohttp.ClientSession(connector=connector, loop=self.loop)
|
self._session = aiohttp.ClientSession(connector=connector, loop=self.loop)
|
||||||
self._locks = weakref.WeakValueDictionary()
|
self._locks = weakref.WeakValueDictionary()
|
||||||
self._global_lock = asyncio.Lock(loop=self.loop)
|
self._global_lock = asyncio.Lock(loop=self.loop)
|
||||||
self.token = None
|
self.token = None
|
||||||
@ -133,7 +133,7 @@ class HTTPClient:
|
|||||||
yield from lock
|
yield from lock
|
||||||
with MaybeUnlock(lock) as maybe_lock:
|
with MaybeUnlock(lock) as maybe_lock:
|
||||||
for tries in range(5):
|
for tries in range(5):
|
||||||
r = yield from self.session.request(method, url, **kwargs)
|
r = yield from self._session.request(method, url, **kwargs)
|
||||||
log.debug(self.REQUEST_LOG.format(method=method, url=url, status=r.status, json=kwargs.get('data')))
|
log.debug(self.REQUEST_LOG.format(method=method, url=url, status=r.status, json=kwargs.get('data')))
|
||||||
try:
|
try:
|
||||||
# even errors have text involved in them so this is safe to call
|
# even errors have text involved in them so this is safe to call
|
||||||
@ -219,10 +219,7 @@ class HTTPClient:
|
|||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def close(self):
|
def close(self):
|
||||||
yield from self.session.close()
|
yield from self._session.close()
|
||||||
|
|
||||||
def recreate(self):
|
|
||||||
self.session = aiohttp.ClientSession(connector=self.connector, loop=self.loop)
|
|
||||||
|
|
||||||
def _token(self, token, *, bot=True):
|
def _token(self, token, *, bot=True):
|
||||||
self.token = token
|
self.token = token
|
||||||
|
Loading…
x
Reference in New Issue
Block a user