recurrent 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a45002b50684d1431f2e070a0166a8e77fee134c
4
+ data.tar.gz: 35c41dcb7ddb6a24c60dfb04f89cc17de5c0125d
5
+ SHA512:
6
+ metadata.gz: c9f76d32f033df82b5db2cc0e8b7b5b6df9199e4e22fb50075b0e661569aeddb46e262b95298b01aeaca327692628ea0259634b5e749cd377c831ebca3cf2f8b
7
+ data.tar.gz: a90b47b2381c800d769c88a2f41ee2d45ab6d48d3974911b976726c93173cff1ad5217008435b25f88c73d363129027d2297004965b433341f4740425e9c9d78
data/.gitignore CHANGED
@@ -6,3 +6,5 @@ Gemfile.lock
6
6
  pkg/*
7
7
  /.idea
8
8
  .zenflow-log
9
+ .ruby-version
10
+ .ruby-gemset
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/bin/recurrent CHANGED
@@ -9,8 +9,7 @@ opts = Trollop::options do
9
9
  opt :system, "Command to send to the command line", :type => :string
10
10
  opt :name, "Name of the task", :default => 'command_line'
11
11
  opt :maximum_concurrent_tasks, "Maximum number of concurrent tasks to run", :type => :integer
12
- opt :pool_size, "Size of database connection pool", :type => :integer
13
- opt :locker_pool_size, "Size of locker database connection pool (should be >= maximum_concurrent_tasks)", :type => :integer
12
+ opt :process_name, "Name of the worker process", :type => :string
14
13
  end
15
14
 
16
15
  begin
@@ -18,5 +17,5 @@ begin
18
17
  rescue LoadError
19
18
  require 'recurrent'
20
19
  end
21
- $0 = "recurrent:worker:started-#{Time.now.to_s(:logging)}"
20
+ $0 = opts[:process_name] || "recurrent:worker:started-#{Time.now.to_s(:logging)}"
22
21
  Recurrent::Worker.new(opts).start
@@ -3,7 +3,7 @@ module Recurrent
3
3
 
4
4
  class << self
5
5
 
6
- attr_accessor :logging, :wait_for_running_tasks_on_exit_for, :maximum_concurrent_tasks, :pool_size, :locker_pool_size
6
+ attr_accessor :logging, :wait_for_running_tasks_on_exit_for, :maximum_concurrent_tasks
7
7
 
8
8
  def self.block_accessor(*fields)
9
9
  fields.each do |field|
@@ -17,12 +17,15 @@ module Recurrent
17
17
 
18
18
  def execute(execution_time)
19
19
  return handle_still_running(execution_time) if running?
20
- return if Configuration.maximum_concurrent_tasks.present? && (scheduler.executing_tasks >= Configuration.maximum_concurrent_tasks)
21
20
  @thread = Thread.new do
22
21
  Thread.current["execution_time"] = execution_time
23
22
  scheduler && scheduler.increment_executing_tasks
24
23
  begin
25
- call_action(execution_time)
24
+ if Configuration.maximum_concurrent_tasks.present?
25
+ call_action(execution_time) unless (scheduler.executing_tasks > Configuration.maximum_concurrent_tasks)
26
+ else
27
+ call_action(execution_time)
28
+ end
26
29
  rescue => e
27
30
  logger.warn("#{name} - #{e.message}")
28
31
  logger.warn(e.backtrace)
@@ -1,3 +1,3 @@
1
1
  module Recurrent
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -5,8 +5,6 @@ module Recurrent
5
5
 
6
6
  def initialize(options={})
7
7
  Configuration.maximum_concurrent_tasks = options[:maximum_concurrent_tasks]
8
- Configuration.pool_size = options[:pool_size]
9
- Configuration.locker_pool_size = options[:locker_pool_size]
10
8
  Configuration.setup.call if Configuration.setup
11
9
  file = options[:file]
12
10
  @scheduler = Scheduler.new(file)
data/spec/task_spec.rb CHANGED
@@ -37,6 +37,7 @@ module Recurrent
37
37
 
38
38
  it "sets its execution_time" do
39
39
  @task.execute(@current_time)
40
+ @task.thread.join
40
41
  @task.thread['execution_time'].should == @current_time
41
42
  end
42
43
 
@@ -51,6 +52,7 @@ module Recurrent
51
52
  it "calls the action with a nil argument" do
52
53
  @task.action.should_receive(:call)
53
54
  @task.execute(@current_time)
55
+ @task.thread.join
54
56
  end
55
57
  end
56
58
 
@@ -62,6 +64,7 @@ module Recurrent
62
64
  it "loads the task return value and calls the action with it as an argument" do
63
65
  @task.action.should_receive(:call).with("testing")
64
66
  @task.execute(@current_time)
67
+ @task.thread.join
65
68
  end
66
69
 
67
70
  after :each do
@@ -111,6 +114,7 @@ module Recurrent
111
114
  context "When no method for handling a still running task is configured" do
112
115
  it "just logs that the task is still running" do
113
116
  @task.logger.should_receive(:info).with("handle_still_running_test: Execution from #{@executing_task_time.to_s(:seconds)} still running, aborting this execution.")
117
+ @task.thread.join
114
118
  @task.handle_still_running(@current_time)
115
119
  end
116
120
  end
@@ -168,6 +172,7 @@ module Recurrent
168
172
  @task = Task.new :name => 'save_results_test', :logger => Logger.new('some identifier')
169
173
  @current_time = Time.now
170
174
  @task.thread = Thread.new { Thread.current["execution_time"] = @current_time }
175
+ @task.thread.join
171
176
  end
172
177
 
173
178
  it "calls the method and logs that the value was saved" do
@@ -201,6 +206,7 @@ module Recurrent
201
206
  t = Task.new
202
207
  t.thread = Thread.new { sleep 1 }
203
208
  t.thread.kill
209
+ sleep 0.1
204
210
  t.running?.should be_false
205
211
  end
206
212
  end
data/spec/worker_spec.rb CHANGED
@@ -36,7 +36,7 @@ module Recurrent
36
36
  waiting_thread = Thread.new { Worker.new.wait_until(Time.local(2011, 7, 26, 11, 40, 00)) }
37
37
  waiting_thread.alive?.should be_true
38
38
  Timecop.travel(Time.local(2011, 7, 26, 11, 40, 00))
39
- sleep(0.5)
39
+ sleep(0.51)
40
40
  waiting_thread.alive?.should be_false
41
41
  Timecop.return
42
42
  end
metadata CHANGED
@@ -1,164 +1,153 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: recurrent
3
- version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease:
6
- segments:
7
- - 0
8
- - 4
9
- - 0
10
- version: 0.4.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Adam Kittelson
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2012-06-14 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2013-09-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: ice_cube
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - "="
27
- - !ruby/object:Gem::Version
28
- hash: 23
29
- segments:
30
- - 0
31
- - 6
32
- - 8
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
33
19
  version: 0.6.8
34
20
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: activesupport
38
21
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.8
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
48
34
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: i18n
52
35
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: i18n
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
62
48
  type: :runtime
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: trollop
66
49
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: trollop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
76
62
  type: :runtime
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
79
- name: rspec
80
63
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
90
76
  type: :development
91
- version_requirements: *id005
92
- - !ruby/object:Gem::Dependency
93
- name: autotest
94
77
  prerelease: false
95
- requirement: &id006 !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: autotest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
104
90
  type: :development
105
- version_requirements: *id006
106
- - !ruby/object:Gem::Dependency
107
- name: timecop
108
91
  prerelease: false
109
- requirement: &id007 !ruby/object:Gem::Requirement
110
- none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
116
- - 0
117
- version: "0"
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: timecop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
118
104
  type: :development
119
- version_requirements: *id007
120
- - !ruby/object:Gem::Dependency
121
- name: pry
122
105
  prerelease: false
123
- requirement: &id008 !ruby/object:Gem::Requirement
124
- none: false
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- hash: 3
129
- segments:
130
- - 0
131
- version: "0"
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
132
118
  type: :development
133
- version_requirements: *id008
134
- - !ruby/object:Gem::Dependency
135
- name: pry-doc
136
119
  prerelease: false
137
- requirement: &id009 !ruby/object:Gem::Requirement
138
- none: false
139
- requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- hash: 3
143
- segments:
144
- - 0
145
- version: "0"
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry-doc
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
146
132
  type: :development
147
- version_requirements: *id009
148
- description: Task scheduler that doesn't need to bootstrap your Rails environment every time it executes a task the way running a rake task via cron does.
149
- email:
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Task scheduler that doesn't need to bootstrap your Rails environment
140
+ every time it executes a task the way running a rake task via cron does.
141
+ email:
150
142
  - adam@zencoder.com
151
- executables:
143
+ executables:
152
144
  - recurrent
153
145
  extensions: []
154
-
155
146
  extra_rdoc_files: []
156
-
157
- files:
147
+ files:
158
148
  - .autotest
159
149
  - .gitignore
160
150
  - .rspec
161
- - .rvmrc
162
151
  - .zenflow
163
152
  - CHANGELOG.md
164
153
  - Gemfile
@@ -185,41 +174,33 @@ files:
185
174
  - spec/worker_spec.rb
186
175
  homepage: http://github.com/zencoder/recurrent
187
176
  licenses: []
188
-
177
+ metadata: {}
189
178
  post_install_message:
190
179
  rdoc_options: []
191
-
192
- require_paths:
180
+ require_paths:
193
181
  - - lib
194
- required_ruby_version: !ruby/object:Gem::Requirement
195
- none: false
196
- requirements:
197
- - - ">="
198
- - !ruby/object:Gem::Version
199
- hash: 3
200
- segments:
201
- - 0
202
- version: "0"
203
- required_rubygems_version: !ruby/object:Gem::Requirement
204
- none: false
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- hash: 3
209
- segments:
210
- - 0
211
- version: "0"
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
212
192
  requirements: []
213
-
214
193
  rubyforge_project:
215
- rubygems_version: 1.8.24
194
+ rubygems_version: 2.0.3
216
195
  signing_key:
217
- specification_version: 3
218
- summary: Task scheduler that doesn't need to bootstrap your Rails environment every time it executes a task the way running a rake task via cron does.
219
- test_files:
196
+ specification_version: 4
197
+ summary: Task scheduler that doesn't need to bootstrap your Rails environment every
198
+ time it executes a task the way running a rake task via cron does.
199
+ test_files:
220
200
  - spec/logger_spec.rb
221
201
  - spec/scheduler_spec.rb
222
202
  - spec/spec_helper.rb
223
203
  - spec/task_collection_spec.rb
224
204
  - spec/task_spec.rb
225
205
  - spec/worker_spec.rb
206
+ has_rdoc:
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm 1.8.7@recurrent