Close HTTP session when logging in fails
Avoids "Unclosed client session" error messages in the terminal
This commit is contained in:
parent
0c0ede8b40
commit
b457f46247
|
@ -51,12 +51,15 @@ class Backend:
|
||||||
device_id: Optional[str] = None,
|
device_id: Optional[str] = None,
|
||||||
homeserver: str = "https://matrix.org",
|
homeserver: str = "https://matrix.org",
|
||||||
) -> Tuple[bool, str]:
|
) -> Tuple[bool, str]:
|
||||||
|
|
||||||
client = MatrixClient(
|
client = MatrixClient(
|
||||||
self, user=user, homeserver=homeserver, device_id=device_id,
|
self, user=user, homeserver=homeserver, device_id=device_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await client.login(password)
|
await client.login(password)
|
||||||
except RuntimeError as err:
|
except RuntimeError as err:
|
||||||
|
await client.close()
|
||||||
return (False, err.args[0].message)
|
return (False, err.args[0].message)
|
||||||
|
|
||||||
self.clients[client.user_id] = client
|
self.clients[client.user_id] = client
|
||||||
|
|
Loading…
Reference in New Issue
Block a user