From 5595548e5ebe961e4757f7768926e7ad355c0027 Mon Sep 17 00:00:00 2001 From: Ricardo Branco Date: Tue, 10 Oct 2023 18:37:29 +0200 Subject: [PATCH] Revert "Use multithreading in guess_service2()" This reverts commit ae2b41bc18930b6ff5be9a7131ec5bdfb95a0913. --- services/guess.py | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/services/guess.py b/services/guess.py index 7c36195..177bffd 100644 --- a/services/guess.py +++ b/services/guess.py @@ -3,7 +3,6 @@ """ import os -from concurrent.futures import ThreadPoolExecutor, as_completed from contextlib import closing from functools import cache from typing import Any @@ -89,28 +88,15 @@ def guess_service2(server: str) -> Any | None: if os.getenv("DEBUG"): session.hooks["response"].append(debugme) - def make_request(method: str, cls: Any, endpoint: str, status: int) -> Any | None: - url = f"https://{server}/{endpoint}" - try: - response = session.request(method, url, timeout=5) - if response.status_code == status: - return cls - except RequestException: - pass - return None - - max_workers = min(10, len(endpoints["GET"]) + len(endpoints["HEAD"])) - with closing(session), ThreadPoolExecutor(max_workers=max_workers) as executor: - futures = [] + with closing(session): for method, want in endpoints.items(): for cls, endpoint, status in want: - futures.append( - executor.submit(make_request, method, cls, endpoint, status) - ) - - for future in as_completed(futures): - result = future.result() - if result: - return result + url = f"https://{server}/{endpoint}" + try: + response = session.request(method, url, timeout=5) + if response.status_code == status: + return cls + except RequestException: + pass return None