s3io:ArgumentError:参数个数错误(1表示0)

时间:2016-01-29 10:18:55

标签: ruby-on-rails ruby sidekiq aws-sdk

我的制作应用程序中存在非常奇怪的问题。在我的一个使用sidekiq的工人中,我有这样的代码:

  def unzip_file_to_bucket(file_url, filename)
    S3io.open(upload_bucket.objects[filename], 'w', max_file_size: 0) do |os|
      Zip::File.open(open(file_url)) do |zip|
        zip.first.get_input_stream do |is|
          while buf = is.sysread(::Zip::Decompressor::CHUNK_SIZE, buf)
            os << buf
          end
        end
      end
    end
  end

  def upload_bucket
    AWS::S3.new(access_key_id: ENV['AWS_ACCESS_KEY_ID_IO'], secret_access_key: ENV['AWS_SECRET_ACCESS_KEY_IO']).buckets[ENV['AWS_BUCKET_IO']]
  end

此代码有时会返回以下错误:ArgumentError: wrong number of arguments (1 for 0)

这是stacktrace:

ArgumentError: wrong number of arguments (1 for 0)
  from celluloid/tasks/task_fiber.rb:15:in `block in create'
  from celluloid/tasks.rb:57:in `block in initialize'
  from celluloid/actor.rb:357:in `block in task'
  from celluloid/cell.rb:71:in `block in task'
  from celluloid/cell.rb:60:in `block in invoke'
  from celluloid/calls.rb:122:in `dispatch'
  from celluloid/calls.rb:26:in `dispatch'
  from celluloid/calls.rb:26:in `public_send'
  from sidekiq/processor.rb:50:in `process'
  from sidekiq/processor.rb:98:in `stats'
  from sidekiq/processor.rb:51:in `block in process'
  from sidekiq/middleware/chain.rb:132:in `invoke'
  from sidekiq/middleware/chain.rb:132:in `call'
  from sidekiq/middleware/chain.rb:129:in `block in invoke'
  from sidekiq/middleware/server/logging.rb:11:in `call'
  from sidekiq/logging.rb:30:in `with_context'
  from sidekiq/middleware/server/logging.rb:15:in `block in call'
  from sidekiq/middleware/chain.rb:129:in `block in invoke'
  from sidekiq/failures/middleware.rb:9:in `call'
  from sidekiq/middleware/chain.rb:129:in `block in invoke'
  from sidekiq/middleware/server/retry_jobs.rb:74:in `call'
  from sidekiq/middleware/chain.rb:129:in `block in invoke'
  from sidekiq/middleware/server/active_record.rb:6:in `call'
  from sidekiq/middleware/chain.rb:129:in `block in invoke'
  from sidekiq/batch/middleware.rb:25:in `call'
  from sidekiq/middleware/chain.rb:129:in `block in invoke'
  from sidekiq_unique_jobs/middleware/server/unique_jobs.rb:16:in `call'
  from sidekiq/middleware/chain.rb:129:in `block in invoke'
  from sidetiq/middleware/history.rb:8:in `call'
  from sidekiq/middleware/chain.rb:129:in `block in invoke'
  from new_relic/agent/instrumentation/sidekiq.rb:29:in `call'
  from new_relic/agent/instrumentation/controller_instrumentation.rb:352:in `perform_action_with_newrelic_trace'
  from new_relic/agent/instrumentation/sidekiq.rb:33:in `block in call'
  from sidekiq/middleware/chain.rb:127:in `block in invoke'
  from sidekiq/processor.rb:52:in `block (2 levels) in process'
  from sidekiq/processor.rb:75:in `execute_job'
  from app/workers/qualtrics_download_job_worker.rb:22:in `perform'
  from app/workers/qualtrics_download_job_worker.rb:37:in `unzip_file_to_bucket'
  from s3io/wrapper.rb:13:in `open'
  from s3io/wrapper.rb:13:in `new'
  from s3io/write_wrapper.rb:30:in `initialize'
  from aws/s3/s3_object.rb:724:in `multipart_upload'
  from aws/s3/object_upload_collection.rb:50:in `create'
  from (eval):3:in `initiate_multipart_upload'
  from aws/core/client.rb:476:in `client_request'
  from aws/core/client.rb:373:in `return_or_raise'
  from aws/core/client.rb:477:in `block in client_request'
  from aws/core/client.rb:391:in `log_client_request'
  from aws/core/client.rb:514:in `block (2 levels) in client_request'
  from aws/core/async_handle.rb:40:in `on_success'
  from aws/core/async_handle.rb:40:in `call'
  from aws/core/client.rb:515:in `block (3 levels) in client_request'
  from aws/s3/client.rb:127:in `block (2 levels) in bucket_method'
  from aws/core/xml/parser.rb:33:in `parse'
  from aws/core/xml/parser.rb:61:in `sax_handler'
  from aws/core/xml/parser.rb:61:in `new'
  from aws/core/xml/parser.rb:61:in `initialize'

任何想法可能是什么问题?

1 个答案:

答案 0 :(得分:2)

听起来像aws-sdk中的自动加载/线程问题。尝试在初始化程序中运行它:

product2