Skip to content

Instantly share code, notes, and snippets.

@kesor

kesor/em-test.rb Secret

Last active December 17, 2015 08:18
Show Gist options
  • Save kesor/b13a1b5289f207931bf4 to your computer and use it in GitHub Desktop.
Save kesor/b13a1b5289f207931bf4 to your computer and use it in GitHub Desktop.
require "em-synchrony"
require "redis/connection/synchrony"
require "redis"
class RequestHandler < EM::P::HeaderAndContentProtocol
attr_accessor :redis
def receive_request(http_headers, http_content)
puts redis.class
# ^^^ this line prints "Redis"
puts redis.smembers 'queues'
# ^^^ this line raises lib/em-synchrony.rb:75:in `yield': can't yield from root fiber (FiberError)
end
end
EM.epoll
EM.synchrony do
redis = Redis.new(path: "/tmp/redis.sock")
EM.start_server("/tmp/server.sock", RequestHandler) do |handler|
handler.redis = redis
end
end
Redis
/tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis/connection/synchrony.rb:81:in `yield': can't yield from root fiber (FiberError)
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis/connection/synchrony.rb:81:in `connect'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis/client.rb:271:in `establish_connection'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis/client.rb:69:in `connect'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis/client.rb:290:in `ensure_connected'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis/client.rb:177:in `block in process'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis/client.rb:256:in `logging'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis/client.rb:176:in `process'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis/client.rb:84:in `call'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis.rb:1247:in `block in smembers'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis.rb:36:in `block in synchronize'
from /usr/local/rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis.rb:36:in `synchronize'
from /tmp/em-test/bundle/ruby/2.0.0/gems/redis-3.0.4/lib/redis.rb:1246:in `smembers'
from em-test.rb:13:in `receive_request'
from /tmp/em-test/bundle/ruby/2.0.0/gems/eventmachine-1.0.3/lib/em/protocols/header_and_content.rb:99:in `dispatch_request'
from /tmp/em-test/bundle/ruby/2.0.0/gems/eventmachine-1.0.3/lib/em/protocols/header_and_content.rb:73:in `receive_line'
from /tmp/em-test/bundle/ruby/2.0.0/gems/eventmachine-1.0.3/lib/em/protocols/linetext2.rb:64:in `receive_data'
from /tmp/em-test/bundle/ruby/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
from /tmp/em-test/bundle/ruby/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
from /tmp/em-test/bundle/ruby/2.0.0/gems/em-synchrony-1.0.3/lib/em-synchrony.rb:38:in `synchrony'
from em-test.rb:23:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment