Permalink
Browse files

! Fixes sporadic hang

  • Loading branch information...
1 parent 00059e9 commit 83db229399de3dedca72013ff3e0f4a3e62468c2 @kschiess committed Jan 23, 2012
Showing with 19 additions and 10 deletions.
  1. +5 −2 lib/procrastinate/process_manager.rb
  2. +14 −8 spec/procrastinate/process_manager_spec.rb
@@ -95,7 +95,9 @@ def wait_for_event
cp_read_end = control_pipe.first
loop do # until we have input in the cp_read_end (control_pipe)
- ready = Cod.select(nil,
+ # TODO Why does procrastinate (cod) hang sometimes when there is no
+ # timeout here? What messages are we missing?
+ ready = Cod.select(1,
:child_msgs => @master, :control_pipe => cp_read_end)
read_child_messages if ready.has_key?(:child_msgs)
@@ -216,9 +218,10 @@ def cleanup
#
def wait_for_all_childs
# TODO Maybe signal KILL to children after some time.
- until children.all? { |p, c| c.dead? }
+ until children.empty?
wait_for_event
reap_childs
+ finalize_children
end
end
end
@@ -9,12 +9,18 @@
its(:process_count) { should == 0}
- # context "when one process is running" do
- # class Task
- # def run(endpoint)
- #
- # end
- # end
- # before(:each) { subject.create_process() }
- # end
+ describe '#wait_for_all_childs' do
+ describe 'with a fake child' do
+ let(:child) { Procrastinate::ProcessManager::ChildProcess.new(nil, nil) }
+ before(:each) { manager.children[1234] = child }
+
+ it "correctly cleans up children" do
+ child.start
+ child.sigchld_received
+
+ manager.wakeup
+ manager.teardown
+ end
+ end
+ end
end

0 comments on commit 83db229

Please sign in to comment.