Skip to content

Commit

Permalink
修复self.proxy为None时产生的报错 (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
acgloli authored Oct 5, 2023
1 parent 0022e03 commit c3dbfda
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion live_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,17 @@ async def request(self, method, url, **kwargs):
raise ConnectionError(f'{self.flag}直播检测请求错误\n{repr(error)}')

def get_client(self):
# 检查是否有设置代理
if self.proxy:
transport = AsyncProxyTransport.from_url(self.proxy)
else:
transport = None

return httpx.AsyncClient(
http2=True,
timeout=self.interval,
limits=httpx.Limits(max_keepalive_connections=100, keepalive_expiry=self.interval * 2),
transport=AsyncProxyTransport.from_url(self.proxy),
transport=transport,
headers=self.headers,
cookies=self.cookies
)
Expand Down

0 comments on commit c3dbfda

Please sign in to comment.