Skip to content

Commit 6936432

Browse files
Update download.py
1 parent 74dc8a1 commit 6936432

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tuf/download.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import os
3232
import socket
3333
import logging
34+
import time
3435
import timeit
3536
import ssl
3637

@@ -317,7 +318,10 @@ def _download_fixed_amount_of_data(connection, temp_file, required_length):
317318
while True:
318319
# We download a fixed chunk of data in every round. This is so that we
319320
# can defend against slow retrieval attacks. Furthermore, we do not wish
320-
# to download an extremely large file in one shot.
321+
# to download an extremely large file in one shot. Before beginning the
322+
# round, sleep for a short amount of time so that the CPU is not hogged
323+
# in the while loop.
324+
time.sleep(0.05)
321325
data = b''
322326
read_amount = min(tuf.conf.CHUNK_SIZE,
323327
required_length - number_of_bytes_received)

0 commit comments

Comments
 (0)