From 997ab7a770da221484c29a9d1a4b77d05114776a Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 19 Aug 2014 14:59:40 +1000 Subject: [PATCH] FIX: signaling seems flaky, simply kill thread --- lib/sidekiq/pausable.rb | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/sidekiq/pausable.rb b/lib/sidekiq/pausable.rb index 7e859ab6d34..344c88b2bd1 100644 --- a/lib/sidekiq/pausable.rb +++ b/lib/sidekiq/pausable.rb @@ -3,7 +3,6 @@ require 'thread' class SidekiqPauser def initialize @mutex = Mutex.new - @done = ConditionVariable.new end def pause! @@ -21,19 +20,12 @@ class SidekiqPauser end def unpause! - # concurrency is hard, perform signaling from a bg thread - # otherwise it acts weird - Thread.new do - @mutex.synchronize do - if @pause_thread - @paused = false - @done.signal - end - end - end.join - @mutex.synchronize do - @pause_thread.join if @pause_thread + if @pause_thread + @paused = false + end + @pause_thread.kill + @pause_thread.join @pause_thread = nil end @@ -50,11 +42,7 @@ class SidekiqPauser Sidekiq.redis do |r| r.setex paused_key, 60, "paused" end - - @mutex.synchronize do - return unless @paused - @done.wait(@mutex, 30) - end + sleep 30 end end end