remove pool manager and threads

This commit is contained in:
rmanach 2023-08-14 23:45:40 +02:00
parent 26ff59eb8d
commit 1dc9fccdc4

View File

@ -5,9 +5,6 @@ import shutil
import time
import urllib3
from threading import Thread
from urllib3 import PoolManager
FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
logging.basicConfig(format=FORMAT, level=logging.INFO)
@ -29,9 +26,9 @@ FILES = (
)
def get_files(http: PoolManager, filename: str, outdir: str):
def get_file(filename: str, outdir: str):
with open(os.path.join(outdir, filename), "wb") as out:
r = http.request("GET", f"{URL}/{filename}", preload_content=False)
r = urllib3.request("GET", f"{URL}/{filename}", preload_content=False)
shutil.copyfileobj(r, out)
@ -56,15 +53,7 @@ if __name__ == "__main__":
logging.fatal(e)
exit(1)
threads = []
http = urllib3.PoolManager()
for f in FILES:
t = Thread(target=get_files, args=[http, f, jaymod_dir])
threads.append(t)
t.start()
for t in threads:
t.join()
get_file(f, jaymod_dir)
logging.info(f"elapsed time: {time.perf_counter() - start:.2f}s")