multithreading - Rails, ActionController::Live, Puma: ThreadError -


i want stream notification client. this, use redis pup/sub , actioncontroller::live. here streamingcontroller looks like:

class streamingcontroller < actioncontroller::base   include actioncontroller::live    def stream     response.headers['content-type'] = 'text/event-stream'      $redis.psubscribe("user-#{params[:user_id]}:*") |on|       on.pmessage |subscription, event, data|         response.stream.write "data: #{data}\n\n"       end     end   rescue ioerror     logger.info "stream closed"   ensure     response.stream.close   end end 

here js part listen stream:

var source = new eventsource("/stream?user_id=" + user_id); source.addeventlistener("message", function(e) {   data = jquery.parsejson(e.data);    switch(data.type) {     case "unread_receipts":       updateunreadreceipts(data);       break;   } }, false); 

now if push redis, client gets push-notification. works fine. when click on link nothing happening. after canceling rails server (i use puma) ctrl+c got following error:

threaderror: attempt unlock mutex locked thread

the problem can solved after adding config.middleware.delete rack::lock development.rb, don't see console output after pushing client. config.cache_classes = true , config.eager_load = trueare no options because don't want restart server every time in development.

is there other solution?

if want avoid restarting server pick changes think you'd need running multiple processes.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -