1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-27 07:33:05 +00:00

add timeout

This commit is contained in:
nishiki 2014-08-31 10:59:33 +02:00
parent 4a564dd07e
commit 1390850e18

View file

@ -11,6 +11,7 @@ module MPW
require 'i18n'
require 'socket'
require 'json'
require 'timeout'
class MPWSync
@ -37,9 +38,20 @@ module MPW
@password = password
@suffix = path
Timeout.timeout(10) do
begin
TCPSocket.open(@host, @port) do
puts 'testi2'
@enable = true
end
rescue Errno::ENETUNREACH
retry
end
end
rescue Timeout::Error
puts 'timeout'
@error_msg = "#{I18n.t('error.timeout')}\n#{e}"
@enable = false
rescue Exception => e
@error_msg = "#{I18n.t('error.sync.connection')}\n#{e}"
@enable = false