gpt4 book ai didi

ruby - 法拉第的 "timeout"和 "open timeout"是什么?

转载 作者:数据小太阳 更新时间:2023-10-29 06:25:01 28 4
gpt4 key购买 nike

由于 Faraday 没有文档,我无法在任何地方找到它。法拉第什么是“timeout”,什么是“open timeout”?

最佳答案

如果您在 https://github.com/lostisland/faraday/blob/master/lib/faraday/request.rb 查看源代码然后你会看到:

#   :timeout      - open/read timeout Integer in seconds
# :open_timeout - read timeout Integer in seconds

也许不是很有帮助?好吧,如果您在 https://github.com/lostisland/faraday/blob/master/lib/faraday/adapter/net_http.rb 查看 Faraday 的 Net::HTTP 适配器,你会看到:

http.read_timeout = http.open_timeout = req[:timeout] if req[:timeout]
http.open_timeout = req[:open_timeout] if req[:open_timeout]

所以 Faraday 的 open_timeout 等同于 Net::HTTP 的 open_timeout,记录为:

Number of seconds to wait for the connection to open. Any number may be used, including Floats for fractional seconds. If the HTTP object cannot open a connection in this many seconds, it raises a TimeoutError exception.

Faraday 的 timeout 等同于 Net::HTTP 的 read_timeout,记录为:

Number of seconds to wait for one block to be read (via one read(2) call). Any number may be used, including Floats for fractional seconds. If the HTTP object cannot read data in this many seconds, it raises a TimeoutError exception.

关于ruby - 法拉第的 "timeout"和 "open timeout"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10322283/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com