向本地开发服务器发出请求时,jruby IO.popen读取将挂起 [英] jruby IO.popen read hangs in action when requests are made to the local dev server
本文介绍了向本地开发服务器发出请求时,jruby IO.popen读取将挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想将wkhtmltopdf的输出发送给用户.它不应该那么难.
I just want to send the output of wkhtmltopdf to the user. It shouldn't be so hard.
def it
send_pdf "file.pdf"
end
def send_pdf(file)
url= url_for(params) # Example: http://localhost:3000/report/it
webkit= Rails.root.join('app', 'bin', 'wkhtmltopdf', 'current')
cmd= "#{webkit} -q \"#{url_for(params)}\" -"
data= IO.popen(cmd).read ############### HANGS HERE ###################
send_data(data, type: "application/pdf", filename: file)
end
为什么挂起以及如何修复它?
Why does it hang and how to fix it?
推荐答案
我认为这里的线索可能是本地开发服务器-因此也许一次只能接受一个请求.
I think the clue here may be it's a local development server - so maybe it can only accept one request at a time.
要进行测试,请尝试从其他位置获取html:
To test, try getting the html from somewhere else:
def send_pdf(file)
# [...]
cmd= "#{webkit} -q http://brighterplanet.com -"
# [...]
end
如果这行得通,那么您的问题的答案是开发服务器是单线程".
If that works, then the answer to your question is that the development server is "single-threaded".
这篇关于向本地开发服务器发出请求时,jruby IO.popen读取将挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文