Skip to content

Instantly share code, notes, and snippets.

@ggayan
Created July 31, 2013 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ggayan/6126358 to your computer and use it in GitHub Desktop.
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
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
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