mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 21:39:49 +00:00
consolidate rand_sleep
This commit is contained in:
@@ -9,6 +9,7 @@ import random
|
||||
import string
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
from typing import Any
|
||||
from urllib.parse import urlparse
|
||||
|
||||
@@ -40,16 +41,14 @@ def randomizor(length: int) -> str:
|
||||
return "".join(random.choice(pool) for i in range(length))
|
||||
|
||||
|
||||
def get_sleep(config) -> int:
|
||||
"""get randomized sleep"""
|
||||
def rand_sleep(config) -> None:
|
||||
"""randomized sleep based on config"""
|
||||
sleep_config = config["downloads"].get("sleep_interval")
|
||||
if not sleep_config:
|
||||
return 0
|
||||
return
|
||||
|
||||
rand_sleep = random.randrange(
|
||||
int(sleep_config * 0.5), int(sleep_config * 1.5)
|
||||
)
|
||||
return rand_sleep
|
||||
secs = random.randrange(int(sleep_config * 0.5), int(sleep_config * 1.5))
|
||||
sleep(secs)
|
||||
|
||||
|
||||
def requests_headers() -> dict[str, str]:
|
||||
|
||||
Reference in New Issue
Block a user