From 7acd7ffc02d14d175ec2a99ba984e47d8cb65d7d Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Wed, 14 Apr 2021 17:23:15 +0200 Subject: [enh] rewrite and enhance metrics --- searx/network/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'searx/network/__init__.py') diff --git a/searx/network/__init__.py b/searx/network/__init__.py index dbd31c781..40665f7d6 100644 --- a/searx/network/__init__.py +++ b/searx/network/__init__.py @@ -3,7 +3,7 @@ import asyncio import threading import concurrent.futures -from time import time +from timeit import default_timer import httpx import h2.exceptions @@ -65,7 +65,7 @@ def get_context_network(): def request(method, url, **kwargs): """same as requests/requests/api.py request(...)""" - time_before_request = time() + time_before_request = default_timer() # timeout (httpx) if 'timeout' in kwargs: @@ -82,7 +82,7 @@ def request(method, url, **kwargs): timeout += 0.2 # overhead start_time = getattr(THREADLOCAL, 'start_time', time_before_request) if start_time: - timeout -= time() - start_time + timeout -= default_timer() - start_time # raise_for_error check_for_httperror = True @@ -111,7 +111,7 @@ def request(method, url, **kwargs): # update total_time. # See get_time_for_thread() and reset_time_for_thread() if hasattr(THREADLOCAL, 'total_time'): - time_after_request = time() + time_after_request = default_timer() THREADLOCAL.total_time += time_after_request - time_before_request # raise an exception -- cgit v1.2.3-54-g00ecf