def imap_watchdog
      Thread.new do
        loop do
          begin
            Clacks.logger.debug('watchdog sleeps')
            sleep(WATCHDOG_SLEEP)
            Clacks.logger.debug('watchdog woke up')
            @imap.idle_done
            Clacks.logger.debug('watchdog signalled idle process')
          rescue StandardError => e
            Clacks.logger.debug { "watchdog received error: #{e.message} (#{e.class})\n#{(e.backtrace || []).join("\n")}" }
            # noop
          rescue Exception => e
            fatal(e)
          end
        end
      end
    end
def imap_watchdog
      Thread.new do
        loop do
          begin
            Clacks.logger.debug('watchdog sleeps')
            sleep(WATCHDOG_SLEEP)
            Clacks.logger.debug('watchdog woke up')
            @imap.idle_done
            Clacks.logger.debug('watchdog signalled idle process')
          rescue StandardError => e
            Clacks.logger.debug { "watchdog received error: #{e.message} (#{e.class})\n#{(e.backtrace || []).join("\n")}" }
            # noop
          rescue Exception => e
            fatal(e)
          end
        end
      end
    end
http://tools.ietf.org/rfc/rfc2177.txt