Skip to content

read_timeout not working #73

@wf5w

Description

@wf5w

I am running with: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu] on Linux Mint 20.3

I have the following code snippet, but here is what I would expect: I would expect that after say 250 ms, that if there was no input then an error would be produced. EIO? but if a character came then the loop would continue. What is actually happening is nothing, it just hangs:

bytes = []

begin
  sp.read_timeout = 250
  puts "read timeout is set to: #{sp.read_timeout}\n"

  while 1
   bytes << sp.getc
   print bytes.last
    if bytes.last == 0xFD
      break
    end
  end
rescue => e
  unless e.class == Errno::EIO
    puts error.inspect
  end
end

puts "\n\nreceived: #{bytes.join('')}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions