From 6152e33454a652c9942756c70f585f2f410ff306 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 26 Jun 2018 15:48:38 +0200 Subject: [PATCH] Fix sync run_until_disconnected not liking Ctrl+C --- telethon/client/updates.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/telethon/client/updates.py b/telethon/client/updates.py index d509abc4..f2247c5a 100644 --- a/telethon/client/updates.py +++ b/telethon/client/updates.py @@ -32,11 +32,12 @@ class UpdateMethods(UserMethods): If the loop is already running, this method returns a coroutine that you should await on your own code. """ - coro = self._run_until_disconnected() - return ( - coro if self.loop.is_running() - else self.loop.run_until_complete(coro) - ) + if self.loop.is_running(): + return self._run_until_disconnected() + try: + return self.loop.run_until_complete(self.disconnected) + except KeyboardInterrupt: + self.loop.run_until_complete(self.disconnect()) def on(self, event): """