searx/poolrequests.py
def request(method, url, **kwargs):
    """same as requests/requests/api.py request(...)"""
    time_before_request = time()

    # session start
    session = SessionSinglePool()

    # proxies
    kwargs['proxies'] = settings['outgoing'].get('proxies') or None

    # timeout
    if 'timeout' in kwargs:
        timeout = kwargs['timeout']
    else:
        timeout = getattr(threadLocal, 'timeout', None)
        if timeout is not None:
            kwargs['timeout'] = timeout

    # do request
    response = session.request(method=method, url=url, **kwargs)

    time_after_request = time()

    # is there a timeout for this engine ?
    if timeout is not None:
        timeout_overhead = 0.2  # seconds
        # start_time = when the user request started
        start_time = getattr(threadLocal, 'start_time', time_before_request)
        search_duration = time_after_request - start_time
        if search_duration > timeout + timeout_overhead:
            raise requests.exceptions.Timeout(response=response)

    # session end
    session.close()

    if hasattr(threadLocal, 'total_time'):
        threadLocal.total_time += time_after_request - time_before_request

    return response
def request(method, url, **kwargs):
    """same as requests/requests/api.py request(...)"""
    time_before_request = time()

    # session start
    session = SessionSinglePool()

    # proxies
    kwargs['proxies'] = settings['outgoing'].get('proxies') or None

    # timeout
    if 'timeout' in kwargs:
        timeout = kwargs['timeout']
    else:
        timeout = getattr(threadLocal, 'timeout', None)
        if timeout is not None:
            kwargs['timeout'] = timeout

    # do request
    response = session.request(method=method, url=url, **kwargs)

    time_after_request = time()

    # is there a timeout for this engine ?
    if timeout is not None:
        timeout_overhead = 0.2  # seconds
        # start_time = when the user request started
        start_time = getattr(threadLocal, 'start_time', time_before_request)
        search_duration = time_after_request - start_time
        if search_duration > timeout + timeout_overhead:
            raise requests.exceptions.Timeout(response=response)

    # session end
    session.close()

    if hasattr(threadLocal, 'total_time'):
        threadLocal.total_time += time_after_request - time_before_request

    return response
def request ( method , url , * * kwargs ) : time_before_request = time ( ) # session start session = SessionSinglePool ( ) # proxies kwargs [ 'proxies' ] = settings [ 'outgoing' ] . get ( 'proxies' ) or None # timeout if 'timeout' in kwargs : timeout = kwargs [ 'timeout' ] else : timeout = getattr ( threadLocal , 'timeout' , None ) if timeout is not None : kwargs [ 'timeout' ] = timeout # do request response = session . request ( method = method , url = url , * * kwargs ) time_after_request = time ( ) # is there a timeout for this engine ? if timeout is not None : timeout_overhead = 0.2 # seconds # start_time = when the user request started start_time = getattr ( threadLocal , 'start_time' , time_before_request ) search_duration = time_after_request - start_time if search_duration > timeout + timeout_overhead : raise requests . exceptions . Timeout ( response = response ) # session end session . close ( ) if hasattr ( threadLocal , 'total_time' ) : threadLocal . total_time += time_after_request - time_before_request return response
same as requests/requests/api.py request(...)
same as requests / requests / api . py request ( ... )