Created
July 31, 2013 21:28
-
-
Save ggayan/6126358 to your computer and use it in GitHub Desktop.
Code for reproducing ERROR -- : RedisActor: CLEANUP CRASHED! IOError: selector is closed with celluloid-redis nio4r v0.4.6 produces a segfault. For running the example use bundle && bundle exec ruby app.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'logger' | |
require 'celluloid/autostart' | |
require 'celluloid/io' | |
require 'celluloid/redis' | |
class RedisActor | |
include Celluloid::IO | |
def initialize(host, channel_name) | |
@host = host | |
@channel_name = channel_name | |
@redis = ::Redis.new host: @host, driver: :celluloid | |
@logger = ::Logger.new(STDOUT) | |
async.subscribe_to_channel | |
end | |
def subscribe_to_channel | |
begin | |
@redis.subscribe(@channel_name) do |on| | |
on.subscribe do |channel, subscriptions| | |
@logger.info "subscribed to ##{channel}" | |
end | |
on.message do |_,m| | |
@logger.info "received message" | |
end | |
on.unsubscribe do |channel, subscriptions| | |
@logger.info "unsubscribed from ##{channel}" | |
end | |
end | |
rescue ::Redis::BaseConnectionError => error | |
@logger.info "#{error}, retrying in 1s." | |
sleep 1 | |
retry | |
end | |
end | |
end | |
class AppGroup < Celluloid::SupervisionGroup | |
supervise RedisActor, args: ['localhost', 'some_channel'] | |
end | |
AppGroup.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org' | |
gem 'nio4r', github: 'celluloid/nio4r', branch: 'master' | |
gem 'celluloid-io' | |
gem 'celluloid-redis' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment