Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After unsubscribe() Connection thinks it is still subscribed #106

Closed
stefanwille opened this issue Jun 23, 2020 · 0 comments
Closed

After unsubscribe() Connection thinks it is still subscribed #106

stefanwille opened this issue Jun 23, 2020 · 0 comments
Labels

Comments

@stefanwille
Copy link
Owner

As mentioned here: #83

require "redis"

redis = Redis::PooledClient.new

sub_connection = redis.pool.checkout
sub_connection.subscribe("foo") do |on|
  on.message do |c, m|
    p({c, m})
    sub_connection.unsubscribe(c)
  end
end

# We're done with pub/sub using sub_connection at this point, return it to the pool:
redis.pool.checkin(sub_connection)

# The following fails because the only connection in the pool was previously
# used for pub/sub, and is still internally configured as such:
# Unhandled exception: Command SET not allowed in the context of a subscribed connection (Redis::Error)
redis.set("foo", "bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant