multithreading - Is it possible to create a thread in Rails subscribe to Redis message channel? -


i trying create thread in rails subscribe message channel of redis. there way this? using unicorn.

i have tried in unicorn configuration this:

after_fork |server, worker|    thread.new     begin       $redis.subscribe(:one, :two) |on|         on.subscribe |channel, subscriptions|           puts "subscribed ##{channel} (#{subscriptions} subscriptions)"         end         on.message |channel, message|           puts "##{channel}: #{message}"           $redis.unsubscribe if message == "exit"         end         on.unsubscribe |channel, subscriptions|           puts "unsubscribed ##{channel} (#{subscriptions} subscriptions)"         end       end     rescue redis::baseconnectionerror => error       puts "#{error}, retrying in 1s"       sleep 1       retry     end   end end 

but make unicorn server unable handle web request. thought if using different thread subscribe redis, won't block main thread; missing here?

the problem here gil in ruby; , client library of redis ruby using loop subscribe command.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -