simple_worker 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/simple_worker/uber_client.rb +18 -0
  2. metadata +11 -11
@@ -46,6 +46,13 @@ module Uber
46
46
  end
47
47
  end
48
48
 
49
+ class TimeoutError < ClientError
50
+ def initialize(msg=nil)
51
+ msg ||= "HTTP Request Timed out."
52
+ super(msg)
53
+ end
54
+ end
55
+
49
56
  class Client
50
57
 
51
58
  def initialize
@@ -54,7 +61,12 @@ module Uber
54
61
 
55
62
  def get(url, req_hash={})
56
63
  if Uber.gem == :typhoeus
64
+ req_hash[:timeout] ||= 1000
57
65
  response = Typhoeus::Request.get(url, req_hash)
66
+ #p response
67
+ if response.timed_out?
68
+ raise TimeoutError
69
+ end
58
70
  else
59
71
  begin
60
72
  headers = req_hash[:headers] || {}
@@ -70,7 +82,13 @@ module Uber
70
82
 
71
83
  def post(url, req_hash={})
72
84
  if Uber.gem == :typhoeus
85
+ # todo: should change this timeout to longer if it's for posting file
86
+ req_hash[:timeout] ||= 1000
73
87
  response = Typhoeus::Request.post(url, req_hash)
88
+ #p response
89
+ if response.timed_out?
90
+ raise TimeoutError
91
+ end
74
92
  else
75
93
  begin
76
94
  headers = req_hash[:headers] || {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-14 00:00:00.000000000 Z
12
+ date: 2011-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: zip
16
- requirement: &9670980 !ruby/object:Gem::Requirement
16
+ requirement: &17566340 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9670980
24
+ version_requirements: *17566340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest-client
27
- requirement: &9674280 !ruby/object:Gem::Requirement
27
+ requirement: &17563920 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *9674280
35
+ version_requirements: *17563920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: zip
38
- requirement: &9694840 !ruby/object:Gem::Requirement
38
+ requirement: &17577080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *9694840
46
+ version_requirements: *17577080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest-client
49
- requirement: &9701440 !ruby/object:Gem::Requirement
49
+ requirement: &17575980 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *9701440
57
+ version_requirements: *17575980
58
58
  description: The official SimpleWorker gem for http://www.simpleworker.com
59
59
  email: travis@appoxy.com
60
60
  executables: []
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 1.8.11
100
+ rubygems_version: 1.8.8
101
101
  signing_key:
102
102
  specification_version: 3
103
103
  summary: The official SimpleWorker gem for http://www.simpleworker.com