使用载波版本时,堆栈级别太深 [英] Stack level too deep when using carrierwave versions

查看:84
本文介绍了使用载波版本时,堆栈级别太深的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用或多或少保存的 sidekiq worker 图像文件到数据库(使用载波)。要保存的文件很少,这是从视频文件中提取的关键帧。

I'm trying to use a sidekiq worker, which more or less saves a image file to database (using carrierwave). There are few files to save, which are a keyframes extracted from a video file. That's what that worker is about.

我的图片上传器已定义了几个版本,如下所示:

My image uploader has a few versions defined and looks as follows:

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:堆栈级别太深,唯一的解决方法是删除我的版本定义。仅当没有任何版本分配给上载程序时,它才有效。

The thing is, when i'm trying to run my Sidekiq Worker, it throws Celluloid::FiberStackError: stack level too deep and the only way to fix that is to remove my version definitions. It works only if there are not any version assigned to the uploader.

我尝试将保存过程移至另一位工作人员或使用Carrierwave :: Backgrounder,但我总是得到相同的结果。

I have tried moving a save process to another worker or using Carrierwave::Backgrounder but i'm allways getting the same result.

您是否知道我该怎么办?

Have you any idea what can i do about it?

编辑:我的stracktrace是:

My stracktrace is:


SystemStackError:
中的堆栈级别太深/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby /2.1.0/irb/workspace.rb:86

SystemStackError: stack level too deep from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/workspace.rb:86


推荐答案

事实证明,这是载波的故障(实际上是osx故障)。带有说明的主题: https://github.com/carrierwaveuploader/carrierwave/issues/1330

It turned out, that it's a carrierwave's fault (well, actually, osx fault). Thread with explanation: https://github.com/carrierwaveuploader/carrierwave/issues/1330

gem 'rmagick', :require => 'RMagick'

这篇关于使用载波版本时,堆栈级别太深的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆