Skip to content

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

@emiltin

Description

@emiltin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions