我试图使用一个 sidekiq worker,它基本上保存一个图像文件到数据库中(使用carrierwave)。需要保存几个文件,这是从视频文件中提取的关键帧。这就是该工人的作用。
我的图像上传器有几个版本定义,并且如下所示:
我的图像上传器有几个版本定义,并且如下所示:
class KeyframeUploader < CarrierWave::Uploader::Base
# ...
# Keyframe thumbnail sizes
version :small do
process resize_to_fill: [180, 180], if: :square?
process resize_to_fill: [320, 180], if: :not_square?
end
version :medium do
process resize_to_fill: [460, 460], if: :square?
process resize_to_fill: [640, 460], if: :not_square?
end
version :large do
process resize_to_fill: [720, 720], if: :square?
process resize_to_fill: [1280, 720], if: :not_square?
end
private
# Checks if image is a square
def square? file
img = Magick::Image.read(file.path)
img[0].columns == img[0].rows
end
# Oposite to #square?
def not_square? file
!square? file
end
end
问题是,当我尝试运行我的Sidekiq Worker时,它会抛出Celluloid::FiberStackError: stack level too deep
,而唯一解决方法是删除上传程序的版本定义。只有在没有分配给上传程序的任何版本时才能正常工作。
我尝试将保存过程移动到另一个Worker或使用Carrierwave::Backgrounder,但结果始终相同。
你有任何想法可以解决吗?
编辑:我的stracktrace是:
SystemStackError: stack level too deep from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/workspace.rb:86