properly stop when credentials are invalid|
This commit is contained in:
parent
c6f3d1cacf
commit
fd4a4408d8
3 changed files with 8 additions and 7 deletions
|
@ -59,10 +59,10 @@ class Client:
|
||||||
):
|
):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
|
|
||||||
self.options = options or {
|
self.options = options or {
|
||||||
"reconnect" : True,
|
"reconnect" : True,
|
||||||
"rctime" : 5.0,
|
"rctime" : 5.0,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.token = token
|
self.token = token
|
||||||
|
|
|
@ -87,11 +87,12 @@ class Dispatcher:
|
||||||
self._dispatching = False
|
self._dispatching = False
|
||||||
if block and self._writer and self._reader:
|
if block and self._writer and self._reader:
|
||||||
await asyncio.gather(self._writer, self._reader)
|
await asyncio.gather(self._writer, self._reader)
|
||||||
if self._up.can_write_eof():
|
if self._up:
|
||||||
self._up.write_eof()
|
if self._up.can_write_eof():
|
||||||
self._up.close()
|
self._up.write_eof()
|
||||||
if block:
|
self._up.close()
|
||||||
await self._up.wait_closed()
|
if block:
|
||||||
|
await self._up.wait_closed()
|
||||||
self._logger.info("Disconnected")
|
self._logger.info("Disconnected")
|
||||||
|
|
||||||
async def connect(self, host:Optional[str] = None, port:Optional[int] = None):
|
async def connect(self, host:Optional[str] = None, port:Optional[int] = None):
|
||||||
|
|
|
@ -102,7 +102,7 @@ class Token:
|
||||||
async with sess.post(endpoint, headers=cls.HEADERS, data=json.dumps(data).encode('utf-8')) as res:
|
async with sess.post(endpoint, headers=cls.HEADERS, data=json.dumps(data).encode('utf-8')) as res:
|
||||||
data = await res.json(content_type=None)
|
data = await res.json(content_type=None)
|
||||||
logging.info(f"Auth request | {data}")
|
logging.info(f"Auth request | {data}")
|
||||||
if res.status != 200:
|
if res.status >= 400:
|
||||||
raise AuthException(f"Action '{endpoint.rsplit('/',1)[1]}' did not succeed")
|
raise AuthException(f"Action '{endpoint.rsplit('/',1)[1]}' did not succeed")
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue