Issue #10031 has been updated by Shugo Maeda.


I've added a new argument `timeout` for Net::IMAP#idle to solve this problem.

For example, the following code checks the connection for each 60 seconds.

    loop do
      imap.idle(60) do |res|
        ...
      end
    end


----------------------------------------
Bug #10031: Net::IMAP idle can still block a thread forever.
https://bugs.ruby-lang.org/issues/10031#change-54523

* Author: James Pike
* Status: Closed
* Priority: Normal
* Assignee: Shugo Maeda
* ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When calling Net::IMAP idle often errors will go unnoticed forever, simply leaving the Thread that called "idle" blocking forever.

For example try bringing your internet connection down whilst a thread is calling the idle method, the calling thread will now be blocked forever.

I've encountered this issue also without losing my internet connection, sometimes the remote server will disconnect the client and the client will never notice leading to the same issue.



-- 
https://bugs.ruby-lang.org/