perennial 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,6 +26,9 @@ end
26
26
 
27
27
  class Perennial::Protocols::PureRuby::JSONTransport
28
28
 
29
+ class Error < StandardError; end
30
+ class NoConnection < Error; end
31
+
29
32
  @@callbacks = {}
30
33
 
31
34
  RETRY_DELAY = 30.0
@@ -51,10 +54,18 @@ class Perennial::Protocols::PureRuby::JSONTransport
51
54
 
52
55
  def read_message
53
56
  with_socket do |s|
54
- message = JSON.parse(s.gets.strip)
55
- return false if !message.is_a?(Hash)
57
+ raise NoConnection, "no connection the server at #{@host}:#{@port}" if s.nil?
58
+ message = nil
59
+ begin
60
+ Perennial::TimerImplementation.timeout(timeout) do
61
+ message = JSON.parse(s.gets.strip)
62
+ end
63
+ rescue Timeout::Error
64
+ return nil, nil
65
+ end
66
+ return nil, nil if !message.is_a?(Hash)
56
67
  action, payload = message["action"], message["payload"]
57
- return false if !action.is_a?(String)
68
+ return nil, nil if !action.is_a?(String)
58
69
  payload = {} unless payload.is_a?(Hash)
59
70
  # We have a processed callback - huzzah!
60
71
  if payload.has_key?("callback-id")
data/lib/perennial.rb CHANGED
@@ -9,7 +9,7 @@ require 'perennial/exceptions'
9
9
 
10
10
  module Perennial
11
11
 
12
- VERSION = [1, 2, 2]
12
+ VERSION = [1, 2, 3]
13
13
 
14
14
  has_library :dispatchable, :hookable, :loader, :logger, :nash,
15
15
  :loggable, :manifest, :settings, :argument_parser,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perennial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-02 00:00:00 +08:00
12
+ date: 2010-01-03 00:00:00 +08:00
13
13
  default_executable: perennial
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency