rufus-scheduler 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,11 @@
2
2
  = rufus-scheduler CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-scheduler - 2.0.6 released 2010/05/01
6
+
7
+ - timeout jobs not outliving their parent job anymore, thanks Joel Wood
8
+
9
+
5
10
  == rufus-scheduler - 2.0.5 released 2010/03/02
6
11
 
7
12
  - fixed parse_time_string(s) issue, thanks Gonzalo Suarez
data/Rakefile CHANGED
@@ -38,9 +38,10 @@ Jeweler::Tasks.new do |gem|
38
38
  gem.test_file = 'spec/spec.rb'
39
39
 
40
40
  #gem.add_dependency 'yajl-ruby'
41
- gem.add_development_dependency 'yard', '>= 0'
42
- gem.add_development_dependency 'bacon', '>= 0'
43
- gem.add_development_dependency 'jeweler', '>= 0'
41
+ gem.add_development_dependency 'rake'
42
+ gem.add_development_dependency 'yard'
43
+ gem.add_development_dependency 'bacon'
44
+ gem.add_development_dependency 'jeweler'
44
45
 
45
46
  # gemspec spec : http://www.rubygems.org/read/chapter/20
46
47
  end
data/TODO.txt CHANGED
@@ -52,3 +52,6 @@
52
52
  [o] unify cron_jobs#trigger_matching_jobs(now) and jobs#job_to_trigger
53
53
  [o] pluggable job queues
54
54
 
55
+ [ ] Joel's complaint about timeout jobs gone ballistic
56
+ [x] move trigger_job out of the scheduler
57
+
@@ -117,6 +117,7 @@ module Scheduler
117
117
 
118
118
  @last = t
119
119
  job_thread = nil
120
+ to_job = nil
120
121
 
121
122
  @scheduler.send(:trigger_job, @params[:blocking]) do
122
123
  #
@@ -131,6 +132,7 @@ module Scheduler
131
132
  trigger_block
132
133
 
133
134
  job_thread = nil
135
+ to_job.unschedule if to_job
134
136
 
135
137
  rescue Exception => e
136
138
 
@@ -143,12 +145,13 @@ module Scheduler
143
145
 
144
146
  if to = @params[:timeout]
145
147
 
146
- @scheduler.in(to, :tags => 'timeout') do
148
+ to_job = @scheduler.in(to, :parent => self, :tags => 'timeout') do
147
149
 
148
150
  # at this point, @job_thread might be set
149
151
 
150
- job_thread.raise(Rufus::Scheduler::TimeOutError) \
151
- if job_thread && job_thread.alive?
152
+ if job_thread && job_thread.alive?
153
+ job_thread.raise(Rufus::Scheduler::TimeOutError)
154
+ end
152
155
  end
153
156
  end
154
157
  end
@@ -168,26 +171,6 @@ module Scheduler
168
171
 
169
172
  @scheduler.unschedule(self.job_id)
170
173
  end
171
-
172
- #--
173
- #protected
174
- #
175
- # Prepare the args given the triggered block arity.
176
- #
177
- #def prepare_args
178
- # if @scheduler.options[:onezero_block_arity]
179
- # case @block.arity
180
- # when 0 then []
181
- # when 1 then [ @params ]
182
- # when 2 then [ @job_id, @params ]
183
- # #else [ @job_id, schedule_info, @params ]
184
- # else [ @job_id, self, @params ]
185
- # end
186
- # else
187
- # [ self ]
188
- # end
189
- #end
190
- #++
191
174
  end
192
175
 
193
176
  #
@@ -219,6 +202,16 @@ module Scheduler
219
202
  #
220
203
  class InJob < SimpleJob
221
204
 
205
+ # If this InJob is a timeout job, parent points to the job that
206
+ # is subject to the timeout.
207
+ #
208
+ attr_reader :parent
209
+
210
+ def initialize (scheduler, t, params)
211
+ @parent = params[:parent]
212
+ super
213
+ end
214
+
222
215
  protected
223
216
 
224
217
  def determine_at
@@ -258,9 +251,6 @@ module Scheduler
258
251
  schedule_next
259
252
 
260
253
  super
261
-
262
- #unschedule if @params[:dont_reschedule]
263
- # obsolete
264
254
  end
265
255
 
266
256
  protected
@@ -26,7 +26,7 @@
26
26
  module Rufus
27
27
  module Scheduler
28
28
 
29
- VERSION = '2.0.5'
29
+ VERSION = '2.0.6'
30
30
  end
31
31
  end
32
32
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rufus-scheduler}
8
- s.version = "2.0.5"
8
+ s.version = "2.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Mettraux"]
12
- s.date = %q{2010-03-02}
12
+ s.date = %q{2010-05-01}
13
13
  s.description = %q{
14
14
  job scheduler for Ruby (at, cron, in and every jobs).
15
15
 
@@ -71,15 +71,18 @@ Gem::Specification.new do |s|
71
71
  s.specification_version = 3
72
72
 
73
73
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
74
+ s.add_development_dependency(%q<rake>, [">= 0"])
74
75
  s.add_development_dependency(%q<yard>, [">= 0"])
75
76
  s.add_development_dependency(%q<bacon>, [">= 0"])
76
77
  s.add_development_dependency(%q<jeweler>, [">= 0"])
77
78
  else
79
+ s.add_dependency(%q<rake>, [">= 0"])
78
80
  s.add_dependency(%q<yard>, [">= 0"])
79
81
  s.add_dependency(%q<bacon>, [">= 0"])
80
82
  s.add_dependency(%q<jeweler>, [">= 0"])
81
83
  end
82
84
  else
85
+ s.add_dependency(%q<rake>, [">= 0"])
83
86
  s.add_dependency(%q<yard>, [">= 0"])
84
87
  s.add_dependency(%q<bacon>, [">= 0"])
85
88
  s.add_dependency(%q<jeweler>, [">= 0"])
@@ -99,5 +99,27 @@ describe "#{SCHEDULER_CLASS} timeouts" do
99
99
  timeouts.size.should.equal(3)
100
100
  timeouts.each { |to| (to * 10).to_i.should.equal(16) }
101
101
  end
102
+
103
+ it 'should point to their "parent" job' do
104
+
105
+ @s.in '1s', :timeout => '3s', :job_id => 'nada' do
106
+ sleep 4
107
+ end
108
+
109
+ sleep 2
110
+
111
+ @s.jobs.values.first.parent.job_id.should.equal('nada')
112
+ end
113
+
114
+ it 'should not survive their job' do
115
+
116
+ @s.in '1s', :timeout => '3s' do
117
+ sleep 0.100
118
+ end
119
+
120
+ sleep 2
121
+
122
+ @s.jobs.size.should.equal(0)
123
+ end
102
124
  end
103
125
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 0
8
- - 5
9
- version: 2.0.5
8
+ - 6
9
+ version: 2.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Mettraux
@@ -14,11 +14,11 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-02 00:00:00 +09:00
17
+ date: 2010-05-01 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: yard
21
+ name: rake
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  requirements:
@@ -30,7 +30,7 @@ dependencies:
30
30
  type: :development
31
31
  version_requirements: *id001
32
32
  - !ruby/object:Gem::Dependency
33
- name: bacon
33
+ name: yard
34
34
  prerelease: false
35
35
  requirement: &id002 !ruby/object:Gem::Requirement
36
36
  requirements:
@@ -42,7 +42,7 @@ dependencies:
42
42
  type: :development
43
43
  version_requirements: *id002
44
44
  - !ruby/object:Gem::Dependency
45
- name: jeweler
45
+ name: bacon
46
46
  prerelease: false
47
47
  requirement: &id003 !ruby/object:Gem::Requirement
48
48
  requirements:
@@ -53,6 +53,18 @@ dependencies:
53
53
  version: "0"
54
54
  type: :development
55
55
  version_requirements: *id003
56
+ - !ruby/object:Gem::Dependency
57
+ name: jeweler
58
+ prerelease: false
59
+ requirement: &id004 !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ type: :development
67
+ version_requirements: *id004
56
68
  description: "\n job scheduler for Ruby (at, cron, in and every jobs).\n\n By default uses a Ruby thread, if EventMachine is present, it will rely on it.\n "
57
69
  email: jmettraux@gmail.com
58
70
  executables: []