Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby ';在rbuf#x27;中进行救援:超时::错误(超时::错误)_Ruby - Fatal编程技术网

Ruby ';在rbuf#x27;中进行救援:超时::错误(超时::错误)

Ruby ';在rbuf#x27;中进行救援:超时::错误(超时::错误),ruby,Ruby,相同的脚本不同的错误。这可能更多地与我的网络相关,而不是与我的代码相关。脚本如下: #!/usr/bin/env ruby -rubygems require File.join(File.dirname(__FILE__), 'authentication') require "csv" # faster_csv (ruby 1.9) lines = CSV.read(File.join(File.dirname(__FILE__), 'karaoke.csv')) # Exported

相同的脚本不同的错误。这可能更多地与我的网络相关,而不是与我的代码相关。脚本如下:

#!/usr/bin/env ruby -rubygems

require File.join(File.dirname(__FILE__), 'authentication')

require "csv" # faster_csv (ruby 1.9)

lines = CSV.read(File.join(File.dirname(__FILE__), 'karaoke.csv')) # Exported an Excel file as CSV

lines.slice!(0) # remove header line

collection = StorageRoom::Collection.find('collection ID')
Song = collection.entry_class

lines.each do |row|
  karaoke = Song.new(:artist => row[0], :song => row[1], :genre => row[2], :file => StorageRoom::File.new_with_filename("#{karaoke.artist}#{karaoke.song}.mov"))

  if karaoke.save
    puts "Song saved: #{karaoke.artist}, #{karaoke.song}, #{karaoke.genre}"
  else
    puts "Song could not be saved: #{karaoke.errors.join(', ')}"
  end
end
错误是:

/usr/local/lib/ruby/1.9.1/net/protocol.rb:140:in `rescue in rbuf_fill': Timeout::Error (Timeout::Error)
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:134:in `rbuf_fill'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
from /usr/local/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
from /usr/local/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1177:in `request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:627:in `start'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1168:in `request'
from /usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib/httparty/request.rb:73:in `perform'
from /usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib/httparty.rb:391:in `perform_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib/httparty.rb:359:in `post'
from /home/hanleyhansen/Desktop/thriventures-storage_room_gem-f7015ed/lib/storage_room/model.rb:69:in `block (2 levels) in create'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:403:in `_run__3801264735883484179__create__2558870880708463764__callbacks'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `__run_callback'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
from /home/hanleyhansen/Desktop/thriventures-storage_room_gem-f7015ed/lib/storage_room/model.rb:68:in `block in create'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:403:in `_run__3801264735883484179__save__2558870880708463764__callbacks'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `__run_callback'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
from /home/hanleyhansen/Desktop/thriventures-storage_room_gem-f7015ed/lib/storage_room/model.rb:67:in `create'
from /home/hanleyhansen/Desktop/thriventures-storage_room_gem-f7015ed/lib/storage_room/model.rb:61:in `save'
from import_csv.rb:17:in `block in <main>'
from import_csv.rb:14:in `each'
from import_csv.rb:14:in `<main>'
/usr/local/lib/ruby/1.9.1/net/protocol.rb:140:in'rescue in rbuf_fill':Timeout::Error(Timeout::Error)
from/usr/local/lib/ruby/1.9.1/net/protocol.rb:134:in'rbuf_fill'
from/usr/local/lib/ruby/1.9.1/net/protocol.rb:116:in'readuntil'
from/usr/local/lib/ruby/1.9.1/net/protocol.rb:126:in'readline'
from/usr/local/lib/ruby/1.9.1/net/http.rb:2219:in'read_status_line'
from/usr/local/lib/ruby/1.9.1/net/http.rb:2208:in'read\u new'
from/usr/local/lib/ruby/1.9.1/net/http.rb:1191:“传输请求”中的
from/usr/local/lib/ruby/1.9.1/net/http.rb:1177:in'request'
from/usr/local/lib/ruby/1.9.1/net/http.rb:1170:in'block in request'
from/usr/local/lib/ruby/1.9.1/net/http.rb:627:in'start'
from/usr/local/lib/ruby/1.9.1/net/http.rb:1168:in'request'
from/usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib/httparty/request.rb:73:in'perform'
从/usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib/httparty.rb:391:“执行请求”中
from/usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib/httparty.rb:359:in'post'
from/home/hanleyhansen/Desktop/thriventures-storage_-room_gem-f7015ed/lib/storage_-room/model.rb:69:在“创建中的块(2层)”中
from/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active\u support/callbacks.rb:403:in``运行` 3801264735883484179\u创建` 2558870708463764\u回调'
来自/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active\u support/callbacks.rb:405:in`\u run\u callback'
来自/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active\u support/callbacks.rb:385:in`_run\u create\u callbacks'
from/home/hanleyhansen/Desktop/thriventures-storage\u room\u gem-f7015ed/lib/storage\u room/model.rb:68:在“创建中的块”中
来自/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active\u-support/callbacks.rb:403:in``运行` 3801264735883484179\u保存` 2558870708463764\u回调'
来自/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active\u support/callbacks.rb:405:in`\u run\u callback'
来自/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active\u support/callbacks.rb:385:in`_run\u save\u callbacks'
from/home/hanleyhansen/Desktop/thriventures-storage\u room\u gem-f7015ed/lib/storage\u room/model.rb:67:in'create'
from/home/hanleyhansen/Desktop/thriventures-storage\u room\u gem-f7015ed/lib/storage\u room/model.rb:61:in'save'
来自import_csv.rb:17:in'block in'
来自import_csv.rb:14:in'each'
从import_csv.rb:14:in`'

我很想知道为什么会发生这个错误以及解决方法。提前谢谢

在浏览网页时发现了这一点。希望它能帮助别人

以下是如何在Net::HTTP API中调整超时:

require 'net/http' 

http = Net::HTTP.new(@host, @port)
http.read_timeout = 500