diff --git a/stream.py b/stream.py index 1584a1a..0eb3304 100755 --- a/stream.py +++ b/stream.py @@ -82,9 +82,11 @@ class ProxyElem(): return data["upstream"] class AsyncSession(): - def __init__(self, session, future): + def __init__(self, session, future, current_proxies, current_proxy): self.session = session self.future = future + self.current_proxies = current_proxies + self.current_proxy = current_proxy proxies = {} for key in providers: @@ -144,7 +146,7 @@ class UpstreamHandler(): current = proxy_list.pop() proxy_list = [current] + proxy_list session = current.session() - delays.append(AsyncSession(session, session.head(src))) + delays.append(AsyncSession(session, session.head(src), current_list, current)) for delay in delays: try: resp = await delay.future @@ -158,8 +160,8 @@ class UpstreamHandler(): else: self.upstream = new_url self.upstream_safe = urllib.parse.quote(new_url) - self.proxy = current - proxies[self.provider] = current_list + self.proxy = delay.current_proxy + proxies[self.provider] = delay.current_proxies for delay in delays: try: await delay.session.close()