【问题标题】:RSpec and Machinist error: Too many open filesRSpec 和机械师错误:打开的文件太多
【发布时间】:2012-02-29 12:43:02
【问题描述】:

今天早上我遇到以下错误:

  14) Deal on creation sets frozen to false or nil
     Failure/Error: Unable to find matching line from backtrace
     Errno::EMFILE:
       Too many open files - identify -format %wx%h '/var/folders/BJ/BJcTANEBFxWcan28U2YEKE+++TI/-Tmp-/stream20120229-36866-4l1sa8.gif[0]'
     # ./spec/support/blueprints.rb:29:in `block in <top (required)>'

规格太慢了(即使使用 spork),所以它们毫无用处。在一个模型中运行 20 个示例需要 9 分钟。 blueprint.rb 中的第 29 行位于以下块之间:

Company.blueprint do
  name { "Office Tronic#{rand(10 ** 10)}" }
  website { 'officetronic.com' }
  subdomain {"officetronic#{rand(10 ** 10)}"}
  facebook { 'officetronic' }
  twitter { 'officetronic' }
  description { 'We are a company dealing with electronics and office supply' }
  address_line1 {'34 John Street'}
  address_line2 {''}
  post_code { 'EC2 3RR' }
  phone { '01 343243434' }
  city { 'London' }
  your_name { 'john Doe' }
  font_colour {'000000'}
  logo_file_name { 'mylogo.png' }  
  logo_content_type { "application/png" }
  logo_file_size { 100 }
end

Deal.blueprint do
  company {Company.make!}
  title { '50% off for web sites dev' }
  description { '50% of discount...' }
  quantity { 1 }
  min_quantity { 0 }
  start_time { Chronic.parse('one month') }
  end_time { Chronic.parse('two months') }
  price { 1500 } # in cents
  shipping_cost{ 100 } # in cents
  published { true }
  small_print { 'Some text' }
  show_map { true }
  post_code { 'E1 6BJ' }
  rrp {15}
end

【问题讨论】:

  • 我意识到使用 spork 时会发生此错误:rspec --drb spec/models/deal_spec.rb

标签: ruby-on-rails rspec machinist


【解决方案1】:

打开的文件过多是操作系统错误,这意味着操作系统已用完文件句柄。 Linux 通常对可以同时打开的文件数量有一个硬性限制,并且已经达到了这个限制。

要临时增加限制,请先运行ulimit -n 8192,然后运行规范。

要永久增加限制,follow these instructions,并将nginx 替换为您用于运行规范的用户帐户的名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 2010-12-07
    • 1970-01-01
    • 2014-06-23
    • 2016-03-17
    • 1970-01-01
    相关资源
    最近更新 更多