Use flush() only if it exists (#1227)

This commit is contained in:
st7105 2019-07-09 16:40:05 +07:00 committed by Lonami
parent 0ced884aa3
commit c4c263a85b

View File

@ -439,7 +439,10 @@ class DownloadMethods:
if inspect.isawaitable(r):
await r
f.flush()
# Not all IO objects have flush (see #1227)
if callable(getattr(f, 'flush', None)):
f.flush()
if in_memory:
return f.getvalue()
finally: