DEV: Fix randomly failing test.

DEV: Fix randomly failing test.

Even if a thread is alive in the loop check, it may be dead by the time Thread#wakeup is called on it.

diff --git a/lib/sidekiq/pausable.rb b/lib/sidekiq/pausable.rb
index 8007a35..57fa221 100644
--- a/lib/sidekiq/pausable.rb
+++ b/lib/sidekiq/pausable.rb
@@ -61,7 +61,14 @@ class SidekiqPauser
     if t = @extend_lease_thread
       @extend_lease_thread = nil
       while t.alive?
-        t.wakeup
+        begin
+          t.wakeup
+        rescue ThreadError => e
+          unless e.message =~ /killed thread/
+            raise e
+          end
+        end
+
         sleep 0
       end
     end

GitHub sha: adbc8785

1 Like