mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
21 lines
364 B
Ruby
21 lines
364 B
Ruby
require 'timeout'
|
|
|
|
module Sidekiq
|
|
module Middleware
|
|
module Server
|
|
class Timeout
|
|
|
|
def call(worker, msg, queue)
|
|
if msg['timeout'] && msg['timeout'].to_i != 0
|
|
::Timeout.timeout(msg['timeout'].to_i) do
|
|
yield
|
|
end
|
|
else
|
|
yield
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|