File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -949,14 +949,20 @@ async def get_file(
949949 offset += limit
950950
951951 if progress :
952- await progress (
952+ func = functools .partial (
953+ progress ,
953954 min (offset , file_size )
954955 if file_size != 0
955956 else offset ,
956957 file_size ,
957958 * progress_args
958959 )
959960
961+ if inspect .iscoroutinefunction (progress ):
962+ await func ()
963+ else :
964+ await self .loop .run_in_executor (self .executor , func )
965+
960966 r = await session .send (
961967 raw .functions .upload .GetFile (
962968 location = location ,
@@ -1035,20 +1041,16 @@ async def get_file(
10351041 offset += limit
10361042
10371043 if progress :
1044+ func = functools .partial (
1045+ progress ,
1046+ min (offset , file_size ) if file_size != 0 else offset ,
1047+ file_size ,
1048+ * progress_args
1049+ )
1050+
10381051 if inspect .iscoroutinefunction (progress ):
1039- await progress (
1040- min (offset , file_size ) if file_size != 0 else offset ,
1041- file_size ,
1042- * progress_args
1043- )
1052+ await func ()
10441053 else :
1045- func = functools .partial (
1046- progress ,
1047- min (offset , file_size ) if file_size != 0 else offset ,
1048- file_size ,
1049- * progress_args
1050- )
1051-
10521054 await self .loop .run_in_executor (self .executor , func )
10531055
10541056 if len (chunk ) < limit :
Original file line number Diff line number Diff line change @@ -183,16 +183,16 @@ async def worker(session):
183183 file_part += 1
184184
185185 if progress :
186+ func = functools .partial (
187+ progress ,
188+ min (file_part * part_size , file_size ),
189+ file_size ,
190+ * progress_args
191+ )
192+
186193 if inspect .iscoroutinefunction (progress ):
187- await progress ( min ( file_part * part_size , file_size ), file_size , * progress_args )
194+ await func ( )
188195 else :
189- func = functools .partial (
190- progress ,
191- min (file_part * part_size , file_size ),
192- file_size ,
193- * progress_args
194- )
195-
196196 await self .loop .run_in_executor (self .executor , func )
197197 except StopTransmission :
198198 raise
You can’t perform that action at this time.
0 commit comments