[Feature #21347] Add open_timeout as an overall timeout option for TCPSocket.new#13909
Merged
shioimm merged 4 commits intoruby:masterfrom Jul 17, 2025
Merged
[Feature #21347] Add open_timeout as an overall timeout option for TCPSocket.new#13909shioimm merged 4 commits intoruby:masterfrom
open_timeout as an overall timeout option for TCPSocket.new#13909shioimm merged 4 commits intoruby:masterfrom
Conversation
…`TCPSocket.new` With this change, `TCPSocket.new` now accepts the `open_timeout` option. This option raises an exception if the specified number of seconds has elapsed since the start of the method call, even if the operation is still in the middle of name resolution or connection attempts. The addition of this option follows the same intent as the previously merged change to `Socket.tcp`. [Feature #21347](https://bugs.ruby-lang.org/issues/21347) ruby#13368
7126eb6 to
636696f
Compare
open_timeout as an overall timeout option for TCPSocket.newopen_timeout as an overall timeout option for TCPSocket.new
This comment has been minimized.
This comment has been minimized.
osyoyu
reviewed
Jul 16, 2025
| # [:resolv_timeout] Specifies the timeout in seconds from when the hostname resolution starts. | ||
| # [:connect_timeout] This method sequentially attempts connecting to all candidate destination addresses.<br>The +connect_timeout+ specifies the timeout in seconds from the start of the connection attempt to the last candidate.<br>By default, all connection attempts continue until the timeout occurs.<br>When +fast_fallback:false+ is explicitly specified,<br>a timeout is set for each connection attempt and any connection attempt that exceeds its timeout will be canceled. | ||
| # [:open_timeout] Specifies the timeout in seconds from the start of the method execution.<br>If this timeout is reached while there are still addresses that have not yet been attempted for connection, no further attempts will be made. | ||
| # [:Specifies the timeout in seconds from the start of the method execution.<br>If this timeout is reached while there are still addresses that have not yet been attempted for connection, no further attempts will be made.<br>If this option is specified together with other timeout options, an +ArgumentError+ will be raised. |
Contributor
There was a problem hiding this comment.
The head of the line ([:open_timeout] Specifies) is destroyed?
Contributor
Author
There was a problem hiding this comment.
Thank you for pointing it out!
636696f to
f59d81c
Compare
Contributor
|
Super cool, thank you!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this change,
TCPSocket.newnow accepts theopen_timeoutoption.This option raises an exception if the specified number of seconds has elapsed since the start of the method call, even if the operation is still in the middle of name resolution or connection attempts.
The addition of this option follows the same intent as the previously merged change to
Socket.tcp.Feature #21347
#13368