Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IO.select not interruptable by Timeout::timeout #1831

Closed
mhoran opened this issue Jul 18, 2014 · 2 comments
Closed

IO.select not interruptable by Timeout::timeout #1831

mhoran opened this issue Jul 18, 2014 · 2 comments
Milestone

Comments

@mhoran
Copy link

mhoran commented Jul 18, 2014

I an attempt to use non-blocking IO to work around the same issue for IO#gets, I discovered that IO.select cannot be interrupted by Timeout::timeout.

I expected the following to work:

read, write = IO.pipe
Timeout::timeout(1) do
  IO.select([read])
end

So long as the read end of the pipe receives no data, and is not closed, this will block forever.

I found that the following results in the desired behavior:

read, write = IO.pipe
Timeout::timeout(1) do
  Thread.new { IO.select([read]) }.join
end

Ideally, Timeout::timeout would not block for IO#gets or IO.select. I've implemented this workaround in capybara-webkit but would prefer a proper solution.

@MSNexploder
Copy link
Contributor

This works as expected in 9.1.9.0 (and 1.7.21):

read, write = IO.pipe
Timeout::timeout(1) do
  IO.select([read])
end

# => "Timeout::Error: execution expired" after one second

@headius
Copy link
Member

headius commented May 21, 2017

Thank you!

@headius headius closed this as completed May 21, 2017
@headius headius added this to the JRuby 9.1.9.0 milestone May 21, 2017
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

No branches or pull requests

3 participants