From b457f462478fbc340280123842e3657685831726 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 27 Aug 2019 14:23:09 -0400 Subject: [PATCH] Close HTTP session when logging in fails Avoids "Unclosed client session" error messages in the terminal --- src/python/backend.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/python/backend.py b/src/python/backend.py index 16dc48da..1cbefb43 100644 --- a/src/python/backend.py +++ b/src/python/backend.py @@ -51,12 +51,15 @@ class Backend: device_id: Optional[str] = None, homeserver: str = "https://matrix.org", ) -> Tuple[bool, str]: + client = MatrixClient( self, user=user, homeserver=homeserver, device_id=device_id, ) + try: await client.login(password) except RuntimeError as err: + await client.close() return (False, err.args[0].message) self.clients[client.user_id] = client