From 11d0eb6ea1e07fddcf58ccaefa8fafb15035d6d8 Mon Sep 17 00:00:00 2001 From: Eric Blundell Date: Tue, 1 May 2018 01:39:58 -0500 Subject: [PATCH] Make sure Session is always stopped upon exceptions in Client.get_file --- pyrogram/client/client.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 1d0ef686..e6028936 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -2696,13 +2696,17 @@ class Client: ) session.start() - - session.send( - functions.auth.ImportAuthorization( - id=exported_auth.id, - bytes=exported_auth.bytes + try: + session.send( + functions.auth.ImportAuthorization( + id=exported_auth.id, + bytes=exported_auth.bytes + ) ) - ) + except Exception as e: + session.stop() + raise e + else: session = Session( dc_id,