镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 06:26:47 +00:00
细分代理场景
这个提交包含在:
12
toolbox.py
12
toolbox.py
@@ -956,7 +956,19 @@ class ProxyNetworkActivate():
|
||||
"""
|
||||
这段代码定义了一个名为TempProxy的空上下文管理器, 用于给一小段代码上代理
|
||||
"""
|
||||
def __init__(self, task=None) -> None:
|
||||
self.task = task
|
||||
if not task:
|
||||
# 不给定task, 那么我们默认代理生效
|
||||
self.valid = True
|
||||
else:
|
||||
# 给定了task, 我们检查一下
|
||||
from toolbox import get_conf
|
||||
WHEN_TO_USE_PROXY, = get_conf('WHEN_TO_USE_PROXY')
|
||||
self.valid = (task in WHEN_TO_USE_PROXY)
|
||||
|
||||
def __enter__(self):
|
||||
if not self.valid: return self
|
||||
from toolbox import get_conf
|
||||
proxies, = get_conf('proxies')
|
||||
if 'no_proxy' in os.environ: os.environ.pop('no_proxy')
|
||||
|
||||
在新工单中引用
屏蔽一个用户