Fix timeouts higher than 60 being ignored
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
from time import perf_counter
|
||||
|
||||
from aiohttp import ClientSession
|
||||
from aiohttp import ClientSession, ClientTimeout
|
||||
from aiohttp.abc import AbstractCookieJar
|
||||
from aiohttp_socks import ProxyConnector, ProxyType
|
||||
|
||||
@@ -21,17 +21,16 @@ class Proxy:
|
||||
sem: asyncio.Semaphore,
|
||||
cookie_jar: AbstractCookieJar,
|
||||
proto: str,
|
||||
timeout: float,
|
||||
timeout: ClientTimeout,
|
||||
) -> None:
|
||||
async with sem:
|
||||
start = perf_counter()
|
||||
async with self.get_connector(proto) as connector:
|
||||
async with ClientSession(
|
||||
connector=connector, cookie_jar=cookie_jar
|
||||
connector=connector, cookie_jar=cookie_jar, timeout=timeout
|
||||
) as session:
|
||||
async with session.get(
|
||||
"http://ip-api.com/json/?fields=8217",
|
||||
timeout=timeout,
|
||||
raise_for_status=True,
|
||||
) as response:
|
||||
data = await response.json()
|
||||
|
||||
@@ -19,7 +19,7 @@ from typing import (
|
||||
Union,
|
||||
)
|
||||
|
||||
from aiohttp import ClientSession, DummyCookieJar
|
||||
from aiohttp import ClientSession, ClientTimeout, DummyCookieJar
|
||||
from rich.console import Console
|
||||
from rich.progress import (
|
||||
BarColumn,
|
||||
@@ -143,7 +143,7 @@ class ProxyScraperChecker:
|
||||
)
|
||||
|
||||
self.sort_by_speed = sort_by_speed
|
||||
self.timeout = timeout
|
||||
self.timeout = ClientTimeout(total=timeout, sock_connect=timeout)
|
||||
self.sources = {
|
||||
proto: frozenset(filter(None, sources.splitlines()))
|
||||
for proto, sources in (
|
||||
@@ -218,7 +218,7 @@ class ProxyScraperChecker:
|
||||
proto: HTTP/SOCKS4/SOCKS5.
|
||||
"""
|
||||
try:
|
||||
async with session.get(source, timeout=15) as response:
|
||||
async with session.get(source) as response:
|
||||
status = response.status
|
||||
text = await response.text()
|
||||
except Exception as e:
|
||||
@@ -272,7 +272,9 @@ class ProxyScraperChecker:
|
||||
)
|
||||
}
|
||||
async with ClientSession(
|
||||
headers=headers, cookie_jar=self.cookie_jar
|
||||
headers=headers,
|
||||
cookie_jar=self.cookie_jar,
|
||||
timeout=ClientTimeout(total=15),
|
||||
) as session:
|
||||
coroutines = (
|
||||
self.fetch_source(
|
||||
|
||||
Reference in New Issue
Block a user