0
在rails應用程序中的請求過程中,我想將數據發佈到另一臺服務器,並且無需等待外部帖子解析即可完成原始請求。我有以下代碼正確發佈,但在繼續之前仍然等待帖子完成。我試過在callback
之外移動EventMachine.stop
,但這只是通過呼叫errback
來結束所有事情。我該怎麼辦?如何使用eventmachine異步處理ruby post請求
EventMachine.run {
http = EventMachine::HttpRequest.new(url).post :body => {body}
http.errback { p 'Uh oh'; EM.stop }
http.callback {
p http.response
EventMachine.stop
}
}
編輯:我沒有嫁給eventmachine這個。如果有更好的解決方案,我全是耳朵。