Skip to content

Start implementing IO#timeout#8662

Open
headius wants to merge 180 commits intojruby:masterfrom
headius:io_timeout
Open

Start implementing IO#timeout#8662
headius wants to merge 180 commits intojruby:masterfrom
headius:io_timeout

Conversation

@headius
Copy link
Member

@headius headius commented Feb 26, 2025

This only implements it for a couple forms of read and for Socket#connect. Other places still need to be wired up.

@headius headius added this to the JRuby 10.0.0.0 milestone Feb 26, 2025
@headius
Copy link
Member Author

headius commented Feb 27, 2025

This may not be the right approach. The select methods called are frequently called in a loop until they produce an error or return a true result. In the cast of Socket#connect, if a timeout is exceeded, it will always return false without raising an error.

We probably need to enhance the RubyThread.select logic to optionally raise a timeout error rather than just return false, since there's no way outside of these methods to determine that the select timed out versus simply selecting nothing.

@headius headius changed the base branch from 10-dev to master March 10, 2025 22:05
@headius headius mentioned this pull request Mar 28, 2025
headius added a commit to headius/jruby that referenced this pull request Apr 2, 2025
IO#timeout is a work in progress.

See jruby#8662
Several updated gems do not have releases yet:

* RubyGems 4.0.0.dev
* bundler 4.0.0.dev
* stringio 3.1.8.dev
* strscan 3.1.6.dev

And the usual CRuby-specific extension gems remain excluded.
This problem does not seem to be going away, so ignore all missing
extensions on JRuby for now.

See ruby/rubygems#3520
We removed the ability to automatically load extensions from jars
many years ago, but this test remained. It only continued to pass
because some other library loaded the 'json' library which meant
that the tested classes were available. When this same example is
run outside of the test suite, it fails:

```
$ cx jruby-10.0.2.0 ruby -e "require 'uri:file:./lib/ruby/stdlib/json/ext/parser'; p JSON::Ext::Parser"
NameError: uninitialized constant JSON::Ext::Parser
  const_missing at org/jruby/RubyModule.java:4866
         <main> at -e:1
```

Because this functionality no longer exists, I am removing the
test.
A few additional stdlib were added in 4.0 so this archive is now
a bit larger.
Testing all of these features together does not show useful
information when one of them is not pre-required, and basing the
spec name off the list of expected features means it cannot be
reliably tagged for exclusion.

The change here makes this a separate subprocess run for each
provided library, which improves the spec in a few different ways:

* Descriptions are meaningful and can be individually tagged.
  Previously, any change to the list of features would cause
  the spec description to change and error output did not clearly
  indicate which feature failed.
* Failed requires are represented with the string "error" so that
  failure output is useful. Previous logic would just report that
  the subprocess failed.
* Implementation-specific features do not have to be filtered out.
  Both CRuby and JRuby have features at boot that do not exist in
  other implementations, and may add others in the future. The spec
  should not need updating when that happens.

The require check and the loaded feature check are combined into a
single run for efficiency.
This spec was split into a separate spec for each feature to avoid
the description changing and to make the failures more useful.
* Removed SortedSet and related files (gem TBD).
* Removed stdlib .rb stub.
* Fixed inspect output, intersect? with Array, and infinite
  enumerables for new tests.
* Moved @hash variable to a bound Java field.
* Fix inspect output expectations.
* Guard SortedSet tests behind a require, since that collection is
  now in a separate library (knu/sorted_set). These tests probably
  should move to the external library once we work out the details
  (see knu/sorted_set#7)
Based on code from CRuby by Tomoya Ishida:

ruby/ruby#13680
When the incoming block's signature is important to the iteration
method being called, the previous logic would hide that signature.
The change here propagates it through the CallBlock.
This does not exactly match the new native Set impl, but it passes
specs and tests related to initialize.
JRuby never loads extensions as .so and pathname is provided as a
pathname.rb.
JRuby does not detect deadlock beyond what JVM already does (only
when dumping thread statuses).
We'll address these in jruby-openssl via fixes in
jruby/jruby-openssl#341 etc.

See jruby#9271
Not sure yet if there's a way to have separate open and connect
timeouts with JVM sockets.
Still not sure I get what "outer" is intended to mean but this
matches CRuby and now there's an equivalent function for
rb_exec_recursive.
This ensures appropriate encoding and path conversion errors are
raised.
Functionality is not yet hooked up.
This only implements it for a couple forms of read and for
Socket#connect. Other places still need to be wired up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants