Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ more shutdown of schedulers (cleaner specs)

  • Loading branch information...
commit 8d82d7e24b8fef2dc9b6486588fd973f9fa65e83 1 parent a5f6143
@kschiess authored
View
2  lib/procrastinate/scheduler.rb
@@ -107,7 +107,7 @@ def shutdown(hard=false)
manager.wakeup
# Wait for the manager to finish its work. This waits for child processes
# and then reaps their result, avoiding zombies.
- @thread.join
+ @thread.join if @thread
end
private
View
2  spec/acceptance/basic_spec.rb
@@ -20,6 +20,8 @@ def the_answer
end
let(:scheduler) { Procrastinate::Scheduler.start }
+ after(:each) { scheduler.shutdown }
+
let(:proxy) { scheduler.proxy(Worker.new) }
describe "Worker writing to a temporary file (orderly shutdown)" do
View
1  spec/acceptance/block_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
describe "Block scheduling" do
+ after(:each) { scheduler.shutdown }
let(:scheduler) { Procrastinate::Scheduler.start }
it "runs blocks in another process" do
View
10 spec/acceptance/throttled_spec.rb
@@ -14,13 +14,14 @@ def run
log.write('B')
end
end
+
+ let(:scheduler) { Procrastinate::Scheduler.start(
+ Procrastinate::SpawnStrategy::Throttled.new(4)) }
+ after(:each) { scheduler.shutdown }
+
attr_reader :log_read, :log_write
attr_reader :trigger_write
- attr_reader :scheduler
before(:each) do
- @scheduler = Procrastinate::Scheduler.start(
- Procrastinate::SpawnStrategy::Throttled.new(4))
-
@log_read, @log_write = IO.pipe
trigger_read, @trigger_write = IO.pipe
@@ -32,7 +33,6 @@ def run
end
after(:each) do
8.times { trigger_write.write '.' }
- scheduler.shutdown
end
# Counts the maximum number of concurrent tasks that have logged to the
View
2  spec/procrastinate/implicit_spec.rb
@@ -10,6 +10,8 @@ def do_something
end
context "when scheduling through Procrastinate module" do
+ before(:each) { Procrastinate.reset }
+
let(:proxy) { Procrastinate.proxy(ImplicitSpecWorker.new) }
subject { proxy.do_something }
before(:each) { subject }
View
6 spec/procrastinate/scheduler_spec.rb
@@ -2,10 +2,8 @@
require 'spec_helper'
describe Procrastinate::Scheduler do
- attr_reader :scheduler
- before(:each) do
- @scheduler = Procrastinate::Scheduler.new(nil)
- end
+ let(:scheduler) { Procrastinate::Scheduler.new(nil) }
+ after(:each) { scheduler.shutdown }
describe "<- #proxy" do
class Worker
Please sign in to comment.
Something went wrong with that request. Please try again.