4

Bugsnag reports that from time to time IO::EAGAINWaitReadable exception is raised in production.

IO::EAGAINWaitReadable: Resource temporarily unavailable - read would block

The exception is raised on HTTP request via HTTParty, ultimately leading to net/protocol.rb:153:in read_nonblock in Ruby 2.1.3.

Why do I get IO::EAGAINWaitReadable? Why are sometimes HTTP requests blocking? And why not let them block, what's the deal?

Nowaker
  • 12,154
  • 4
  • 56
  • 62
  • Possible duplicate of [IO::EAGAINWaitReadable: Resource temporarily unavailable - read would block](http://stackoverflow.com/questions/30669667/ioeagainwaitreadable-resource-temporarily-unavailable-read-would-block) – Малъ Скрылевъ Apr 11 '16 at 15:07

1 Answers1

0

The most general way to handle IO::EAGAINWaitReadable is:

begin
   result = io.read_nonblock(maxlen)
rescue IO::EAGAINWaitReadable
   IO.select([io])
   retry
end

So can do it without selection a port, but better with a selection as it is shewn in the example. Also you can look at the SO answer on how to trap the WaitReadable additionally to the specified.

Community
  • 1
  • 1
Малъ Скрылевъ
  • 16,187
  • 5
  • 56
  • 69