开发者

RoR, page can not be redirected if the action contain thread

开发者 https://www.devze.com 2023-04-07 19:18 出处:网络
I am trying to put some log from the sever to the browser. Here was what I开发者_开发百科 had done:

I am trying to put some log from the sever to the browser. Here was what I开发者_开发百科 had done:

  • step1. start the websocket server in the action create.
  • step2. render the view which contain the websocket client to connect with the server.

step1 works but the client can not be opened in the browser, since the thread is blocked, redirect_to can not be executed.

this is code for detail.

def create
  #some code ...

  th = Thread.new{ start_server }
  format.html { redirect_to(@execution, :notice => 'Execution was successfully created.')}
  th.join
end
0

精彩评论

暂无评论...
验证码 换一张
取 消