From 3e207106c1e584df22b66db92ed96f9ad4225d28 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Fri, 9 Oct 2015 22:21:39 -0700 Subject: [PATCH] Promote Shutdown exception into main module --- lib/sidekiq.rb | 9 +++++++++ lib/sidekiq/cli.rb | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/sidekiq.rb b/lib/sidekiq.rb index 6bed67b9..abea7d31 100644 --- a/lib/sidekiq.rb +++ b/lib/sidekiq.rb @@ -196,6 +196,15 @@ module Sidekiq raise ArgumentError, "Invalid event name: #{event}" unless options[:lifecycle_events].key?(event) options[:lifecycle_events][event] << block end + + # We are shutting down Sidekiq but what about workers that + # are working on some long job? This error is + # raised in workers that have not finished within the hard + # timeout limit. This is needed to rollback db transactions, + # otherwise Ruby's Thread#kill will commit. See #377. + # DO NOT RESCUE THIS ERROR IN YOUR WORKERS + class Shutdown < Interrupt; end + end require 'sidekiq/extensions/class_methods' diff --git a/lib/sidekiq/cli.rb b/lib/sidekiq/cli.rb index 8ee0b87a..9929e8d3 100644 --- a/lib/sidekiq/cli.rb +++ b/lib/sidekiq/cli.rb @@ -11,14 +11,6 @@ require 'sidekiq' require 'sidekiq/util' module Sidekiq - # We are shutting down Sidekiq but what about workers that - # are working on some long job? This error is - # raised in workers that have not finished within the hard - # timeout limit. This is needed to rollback db transactions, - # otherwise Ruby's Thread#kill will commit. See #377. - # DO NOT RESCUE THIS ERROR. - class Shutdown < Interrupt; end - class CLI include Util include Singleton unless $TESTING