ruby rest-client:让它永不超时? [英] ruby rest-client: make it never timeout?

查看:38
本文介绍了ruby rest-client:让它永不超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ruby​​ rest-client 将大量图像上传到我的网站米写作.我的代码看起来像:

I am trying to use ruby rest-client to upload a large number of images to a site that I'm writing. My code looks like:

RestClient.post url, :timeout => 90000000, :open_timeout => 90000000, :file_param => file_obj

但是,我收到此错误:

RestClient::RequestTimeout: Request Timeout
    from /Library/Ruby/Gems/1.8/gems/rest-client-1.6.1/lib/restclient/request.rb:174:in `transmit'
    from /Library/Ruby/

但是当我查看服务器日志时

But when I look at the server log

Completed in 61493ms (View: 2, DB: 1) | 201 Created 

因此似乎没有任何原因导致超时.任何人都知道是否有我没有正确设置的超时参数?

So there doesn't appear to be any reason why this is timing out. Anyone have any idea if there is a timeout param I am not correctly setting?

谢谢

推荐答案

此语法将超时设置为请求头(参见 RestClient.post 签名),如果要使用超时参数必须使用:

This syntax sets the timeout as request header (see RestClient.post signature), if you want to use the timeout parameter you must use:

RestClient::Request.execute(:method => :post, :url => @url, :timeout => 90000000)

参见:https://github.com/rest-client/rest-client/blob/master/lib/restclient/request.rb#L12

这篇关于ruby rest-client:让它永不超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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