From c0412e4410543df223833154b7ac035fc8ac1cc9 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 27 Jun 2018 19:39:47 +0200 Subject: [PATCH] Fix run_until_disconnected disconnect with telethon.sync --- telethon/client/updates.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telethon/client/updates.py b/telethon/client/updates.py index f2247c5a..beaa5119 100644 --- a/telethon/client/updates.py +++ b/telethon/client/updates.py @@ -37,7 +37,12 @@ class UpdateMethods(UserMethods): try: return self.loop.run_until_complete(self.disconnected) except KeyboardInterrupt: - self.loop.run_until_complete(self.disconnect()) + # Importing the magic sync module turns disconnect into sync. + # TODO Maybe disconnect() should not need the magic module... + if inspect.iscoroutinefunction(self.disconnect): + self.loop.run_until_complete(self.disconnect()) + else: + self.disconnect() def on(self, event): """