Support asynchronous progress_callback's

This commit is contained in:
Lonami 2019-07-04 15:34:51 +02:00 committed by GitHub
parent 3f19f6fd50
commit 0d9e639f4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import io
import os
import pathlib
import typing
import inspect
from .. import utils, helpers, errors, hints
from ..requestiter import RequestIter
@ -434,7 +435,9 @@ class DownloadMethods:
input_location, request_size=part_size, dc_id=dc_id):
f.write(chunk)
if progress_callback:
progress_callback(f.tell(), file_size)
r = progress_callback(f.tell(), file_size)
if inspect.isawaitable(r):
await r
f.flush()
if in_memory: