From ee93be9422614304f94fb1c19016cb1747b58535 Mon Sep 17 00:00:00 2001 From: Alexander Zaguzin Date: Tue, 9 Jul 2019 10:35:14 +0700 Subject: [PATCH] Check exist flush method --- telethon/client/downloads.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/telethon/client/downloads.py b/telethon/client/downloads.py index 5f14ceab..c5a00358 100644 --- a/telethon/client/downloads.py +++ b/telethon/client/downloads.py @@ -439,7 +439,9 @@ class DownloadMethods: if inspect.isawaitable(r): await r - f.flush() + if hasattr(f, 'flush') and callable(getattr(f, 'flush')): + f.flush() + if in_memory: return f.getvalue() finally: