- 主题:requests.get timeout不生效
看docker里的进程卡在read(3,.),并不会断开
这是怎么回事
怎么解决
--
FROM 124.222.41.*
resp = requests.get(url, timeout=10)
应该卡在这里
strace -fp 1
strace: Process 1 attached
read(4,
【 在 hgoldfish 的大作中提到: 】
: 有测试代码吗?
--
修改:iwannabe FROM 120.229.14.*
FROM 120.229.14.*
群晖,让系统干净
【 在 JulyClyde 的大作中提到: 】
: 干嘛还放容器里运行啊,感觉有点穿上裤子再放屁
--
FROM 124.222.41.*
从rss里更新pt的
应该卡在第一行
def refresh_rss(url: str, torrent_dir: str) -> bool:
resp = requests.get(url, timeout=10)
if resp.status_code != 200:
logging.warning("Get rss failed with code %d" % resp.status_code)
return False
rss = feedparser.parse(io.BytesIO(resp.content))
for entry in rss.get("entries"):
try:
name = entry.get("title")
_, info = entry.get("links")
if info.get("type") != 'application/x-bittorrent':
continue
torrent_url = info.get("href")
req = requests.get(torrent_url, stream=True)
qname = req.headers.get("content-disposition")
torrent_name = os.path.join(torrent_dir, urllib.parse.unquote(re.f
indall("filename=(.+)", qname)[0]))
logging.info("Get torrent {}".format(name))
if os.path.exists(torrent_name + ".added") or os.path.exists(torre
nt_name):
logging.info("torrent {} has been already downloaded".format(n
ame))
continue
logging.info("save torrent {} to {}".format(name, torrent_name))
with open(torrent_name, "wb") as fp:
for chunk in req.iter_content(65336):
fp.write(chunk)
except Exception as e:
logging.warning(traceback.format_exc())
continue
return True
【 在 hgoldfish 的大作中提到: 】
: 有测试代码吗?
--
FROM 120.229.14.*
看来你是对的,在第二个卡住了
之前没发现
【 在 WanderLife 的大作中提到: 】
: 要不再增加点日志,不止一个requests.get啊
: resp = requests.get(url, timeout=10)
: req = requests.get(torrent_url, stream=True)
: ...................
--
修改:iwannabe FROM 120.229.14.*
FROM 120.229.14.*