mirror of
https://github.com/searxng/searxng
synced 2024-11-05 06:01:05 +00:00
[coding-style] searx/network/network.py - normalized indentations
No functional change! Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
1499002ceb
commit
2128022f72
@ -37,10 +37,12 @@ ADDRESS_MAPPING = {
|
|||||||
|
|
||||||
class Network:
|
class Network:
|
||||||
|
|
||||||
__slots__ = ('enable_http', 'verify', 'enable_http2',
|
__slots__ = (
|
||||||
'max_connections', 'max_keepalive_connections', 'keepalive_expiry',
|
'enable_http', 'verify', 'enable_http2',
|
||||||
'local_addresses', 'proxies', 'max_redirects', 'retries', 'retry_on_http_error',
|
'max_connections', 'max_keepalive_connections', 'keepalive_expiry',
|
||||||
'_local_addresses_cycle', '_proxies_cycle', '_clients')
|
'local_addresses', 'proxies', 'max_redirects', 'retries', 'retry_on_http_error',
|
||||||
|
'_local_addresses_cycle', '_proxies_cycle', '_clients'
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
@ -135,16 +137,18 @@ class Network:
|
|||||||
proxies = next(self._proxies_cycle) # is a tuple so it can be part of the key
|
proxies = next(self._proxies_cycle) # is a tuple so it can be part of the key
|
||||||
key = (verify, max_redirects, local_address, proxies)
|
key = (verify, max_redirects, local_address, proxies)
|
||||||
if key not in self._clients or self._clients[key].is_closed:
|
if key not in self._clients or self._clients[key].is_closed:
|
||||||
self._clients[key] = new_client(self.enable_http,
|
self._clients[key] = new_client(
|
||||||
verify,
|
self.enable_http,
|
||||||
self.enable_http2,
|
verify,
|
||||||
self.max_connections,
|
self.enable_http2,
|
||||||
self.max_keepalive_connections,
|
self.max_connections,
|
||||||
self.keepalive_expiry,
|
self.max_keepalive_connections,
|
||||||
dict(proxies),
|
self.keepalive_expiry,
|
||||||
local_address,
|
dict(proxies),
|
||||||
0,
|
local_address,
|
||||||
max_redirects)
|
0,
|
||||||
|
max_redirects
|
||||||
|
)
|
||||||
return self._clients[key]
|
return self._clients[key]
|
||||||
|
|
||||||
async def aclose(self):
|
async def aclose(self):
|
||||||
@ -166,9 +170,10 @@ class Network:
|
|||||||
|
|
||||||
def is_valid_respones(self, response):
|
def is_valid_respones(self, response):
|
||||||
# pylint: disable=too-many-boolean-expressions
|
# pylint: disable=too-many-boolean-expressions
|
||||||
if (self.retry_on_http_error is True and 400 <= response.status_code <= 599) \
|
if ((self.retry_on_http_error is True and 400 <= response.status_code <= 599)
|
||||||
or (isinstance(self.retry_on_http_error, list) and response.status_code in self.retry_on_http_error) \
|
or (isinstance(self.retry_on_http_error, list) and response.status_code in self.retry_on_http_error)
|
||||||
or (isinstance(self.retry_on_http_error, int) and response.status_code == self.retry_on_http_error):
|
or (isinstance(self.retry_on_http_error, int) and response.status_code == self.retry_on_http_error)
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user