Skip to content
This repository
Browse code

+ more shutdown of schedulers (cleaner specs)

  • Loading branch information...
commit 8d82d7e24b8fef2dc9b6486588fd973f9fa65e83 1 parent a5f6143
Kaspar Schiess authored
2  lib/procrastinate/scheduler.rb
@@ -107,7 +107,7 @@ def shutdown(hard=false)
107 107 manager.wakeup
108 108 # Wait for the manager to finish its work. This waits for child processes
109 109 # and then reaps their result, avoiding zombies.
110   - @thread.join
  110 + @thread.join if @thread
111 111 end
112 112
113 113 private
2  spec/acceptance/basic_spec.rb
@@ -20,6 +20,8 @@ def the_answer
20 20 end
21 21
22 22 let(:scheduler) { Procrastinate::Scheduler.start }
  23 + after(:each) { scheduler.shutdown }
  24 +
23 25 let(:proxy) { scheduler.proxy(Worker.new) }
24 26
25 27 describe "Worker writing to a temporary file (orderly shutdown)" do
1  spec/acceptance/block_spec.rb
... ... @@ -1,6 +1,7 @@
1 1 require 'spec_helper'
2 2
3 3 describe "Block scheduling" do
  4 + after(:each) { scheduler.shutdown }
4 5 let(:scheduler) { Procrastinate::Scheduler.start }
5 6
6 7 it "runs blocks in another process" do
10 spec/acceptance/throttled_spec.rb
@@ -14,13 +14,14 @@ def run
14 14 log.write('B')
15 15 end
16 16 end
  17 +
  18 + let(:scheduler) { Procrastinate::Scheduler.start(
  19 + Procrastinate::SpawnStrategy::Throttled.new(4)) }
  20 + after(:each) { scheduler.shutdown }
  21 +
17 22 attr_reader :log_read, :log_write
18 23 attr_reader :trigger_write
19   - attr_reader :scheduler
20 24 before(:each) do
21   - @scheduler = Procrastinate::Scheduler.start(
22   - Procrastinate::SpawnStrategy::Throttled.new(4))
23   -
24 25 @log_read, @log_write = IO.pipe
25 26 trigger_read, @trigger_write = IO.pipe
26 27
@@ -32,7 +33,6 @@ def run
32 33 end
33 34 after(:each) do
34 35 8.times { trigger_write.write '.' }
35   - scheduler.shutdown
36 36 end
37 37
38 38 # Counts the maximum number of concurrent tasks that have logged to the
2  spec/procrastinate/implicit_spec.rb
@@ -10,6 +10,8 @@ def do_something
10 10 end
11 11
12 12 context "when scheduling through Procrastinate module" do
  13 + before(:each) { Procrastinate.reset }
  14 +
13 15 let(:proxy) { Procrastinate.proxy(ImplicitSpecWorker.new) }
14 16 subject { proxy.do_something }
15 17 before(:each) { subject }
6 spec/procrastinate/scheduler_spec.rb
@@ -2,10 +2,8 @@
2 2 require 'spec_helper'
3 3
4 4 describe Procrastinate::Scheduler do
5   - attr_reader :scheduler
6   - before(:each) do
7   - @scheduler = Procrastinate::Scheduler.new(nil)
8   - end
  5 + let(:scheduler) { Procrastinate::Scheduler.new(nil) }
  6 + after(:each) { scheduler.shutdown }
9 7
10 8 describe "<- #proxy" do
11 9 class Worker

0 comments on commit 8d82d7e

Please sign in to comment.
Something went wrong with that request. Please try again.