diff options
| author | Rapptz <[email protected]> | 2015-12-18 21:18:22 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-12-18 21:18:22 -0500 |
| commit | cf56ddfe4c4c92441408d18a22b5a7ed6de25d78 (patch) | |
| tree | 50e37d70daa8208bc83409f9bf5fea97b201a6ae | |
| parent | Move email out of ConnectionState. (diff) | |
| download | discord.py-cf56ddfe4c4c92441408d18a22b5a7ed6de25d78.tar.xz discord.py-cf56ddfe4c4c92441408d18a22b5a7ed6de25d78.zip | |
Release connection when error occurs during login.
| -rw-r--r-- | discord/client.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/discord/client.py b/discord/client.py index 97915121..58dc855e 100644 --- a/discord/client.py +++ b/discord/client.py @@ -625,10 +625,12 @@ class Client: data = utils.to_json(payload) resp = yield from aiohttp.post(endpoints.LOGIN, data=data, headers=self.headers, loop=self.loop) log.debug(request_logging_format.format(method='POST', response=resp)) - if resp.status == 400: - raise LoginFailure('Improper credentials have been passed.') - elif resp.status != 200: - raise HTTPException(resp, None) + if resp.status != 200: + yield from resp.release() + if resp.status == 400: + raise LoginFailure('Improper credentials have been passed.') + else: + raise HTTPException(resp, None) log.info('logging in returned status code {}'.format(resp.status)) self.email = email |