mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Merge pull request #1608 from sechkova/sleep-before-round
ngclient: remove sleep_before_round
This commit is contained in:
commit
5cdc7dc616
1 changed files with 2 additions and 8 deletions
|
|
@ -6,8 +6,7 @@
|
|||
"""
|
||||
|
||||
import logging
|
||||
import time
|
||||
from typing import Dict, Iterator, Optional
|
||||
from typing import Dict, Iterator
|
||||
from urllib import parse
|
||||
|
||||
# Imports
|
||||
|
|
@ -51,7 +50,6 @@ def __init__(self) -> None:
|
|||
# Default settings
|
||||
self.socket_timeout: int = 4 # seconds
|
||||
self.chunk_size: int = 400000 # bytes
|
||||
self.sleep_before_round: Optional[int] = None
|
||||
|
||||
def fetch(self, url: str) -> Iterator[bytes]:
|
||||
"""Fetches the contents of HTTP/HTTPS url from a remote server
|
||||
|
|
@ -104,11 +102,7 @@ def _chunks(self, response: "requests.Response") -> Iterator[bytes]:
|
|||
# We download a fixed chunk of data in every round. This is
|
||||
# so that we can defend against slow retrieval attacks.
|
||||
# Furthermore, we do not wish to download an extremely
|
||||
# large file in one shot. Before beginning the round, sleep
|
||||
# (if set) for a short amount of time so that the CPU is not
|
||||
# hogged in the while loop.
|
||||
if self.sleep_before_round:
|
||||
time.sleep(self.sleep_before_round)
|
||||
# large file in one shot.
|
||||
|
||||
# NOTE: This may not handle some servers adding a
|
||||
# Content-Encoding header, which may cause urllib3 to
|
||||
|
|
|
|||
Loading…
Reference in a new issue