From 84ba9126f13ec0090dda10f376967ad99c631acf Mon Sep 17 00:00:00 2001 From: fitnr Date: Fri, 13 Nov 2015 10:34:09 -0500 Subject: [PATCH] update default chunk size to 1MB from 4K Add minimum chunk size of 16K, keeps number of chunks under 999 --- tweepy/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tweepy/api.py b/tweepy/api.py index 46a7904..213cb89 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -262,7 +262,11 @@ class API(object): # If a media ID has been generated, we can send the file if media_info.media_id: - chunk_size = kwargs.pop('chunk_size', 4096) + # default chunk size is 1MB, can be overridden with keyword argument. + # minimum chunk size is 16K, which keeps the maximum number of chunks under 999 + chunk_size = kwargs.pop('chunk_size', 1024 * 1024) + chunk_size = max(chunk_size, 16 * 2014) + fsize = os.path.getsize(filename) nloops = int(fsize / chunk_size) + (1 if fsize % chunk_size > 0 else 0) for i in range(nloops): -- 2.25.1