RSpec和机械师错误:打开的文件太多 [英] RSpec and Machinist error: Too many open files

查看:115
本文介绍了RSpec和机械师错误:打开的文件太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天早晨,我遇到以下错误:

This morning I am having the following error:

  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行位于以下块之间:

Specs are so damn slow (even with spork) so they are useless. It takes 9 minutes to run 20 examples in a model. Line 29 in blueprint.rb is between the following blocks:

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

推荐答案

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

Too many open files is an OS error, meaning that the OS has run out of file handles. Linux usually has a hard limit on how many files can be open at the same time, and that limit has been reached.

要临时增加限制,请先运行ulimit -n 8192,然后再运行规格.

To increase the limit temporarily, run ulimit -n 8192 first and then run the specs.

要永久增加该限制,请遵循这些说明,然后将nginx替换为您用于运行规范的用户帐户的名称.

To increase the limit permanently, follow these instructions, and substitute nginx with the name of the user account that you're using to run the specs.

这篇关于RSpec和机械师错误:打开的文件太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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