async icon indicating copy to clipboard operation
async copied to clipboard

with_timeout() cause gets() to raise Errno::ENOENT

Open emiltin opened this issue 2 years ago • 4 comments

Using with_timeout() makes gets() raise Errno::ENOENT. Is this correct? I would have expected Async::TimeoutError.

require 'async'
Async do |task|
  task.with_timeout(0.1) { STDIN.gets }
end

=>

  0.0s     warn: Async::Task [oid=0x64] [ec=0x78] [pid=28789] [2023-06-30 08:53:43 +0200]
               | Task may have ended with unhandled exception.
               |   Errno::ENOENT: No such file or directory @ io_fillbuf - fd:0 <STDIN>
               |   → config/private/async.rb:3 in `gets'
               |     config/private/async.rb:3 in `block (2 levels) in <main>'
               |     /Users/emiltin/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/async-2.6.2/lib/async/scheduler.rb:317 in `with_timeout'
               |     /Users/emiltin/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/async-2.6.2/lib/async/task.rb:126 in `with_timeout'
               |     config/private/async.rb:3 in `block in <main>'
               |     /Users/emiltin/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/async-2.6.2/lib/async/task.rb:180 in `block in run'
               |     /Users/emiltin/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/async-2.6.2/lib/async/task.rb:350 in `block in schedule'


code/rsmp (cli_test_no_shell) % ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
code/rsmp (cli_test_no_shell) % bundle exec gem list async

*** LOCAL GEMS ***

async (2.6.2)
async-io (1.35.0)

This is on MacOS 13.4.1.

emiltin avatar Jun 30 '23 06:06 emiltin

Any input on this?

emiltin avatar Aug 08 '23 09:08 emiltin

I'll take a look, sorry for the delayed response.

ioquatix avatar Aug 08 '23 22:08 ioquatix

If possible, are you able to make a MVP failing test case as a PR? This will help me greatly.

ioquatix avatar Aug 09 '23 06:08 ioquatix

PR in #266

emiltin avatar Aug 09 '23 07:08 emiltin