remember proxy await

This commit is contained in:
Roy Olav Purser 2021-05-14 17:48:52 +02:00
parent 1b86fa591d
commit 372dda4c3b
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -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()