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

Use thread-local for connecting to redis to avoid race conditions on master failover #2

Merged
merged 3 commits into from
Sep 21, 2017

Conversation

lalinsky
Copy link
Contributor

This is a workaround for this problem:

redis/redis-py#732

@lalinsky lalinsky requested review from capkovic and ms7s September 14, 2017 13:53
del config['HOST']
config['UNIX_SOCKET_PATH'] = host
def _strip_dict_prefix(orig, prefix):
return {k[len(prefix):]: v for (k, v) in orig.items() if k.startswith(prefix)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use six.iteritems so that the behaviour for copying the config is consistent between Python 2 and 3.

the_class = config.get(config_key, default_class)
if isinstance(the_class, six.string_types):
the_class = import_string(the_class)
config.pop(config_key, None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to remove the key from config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted the config to be clean when it's passed to the function that matches the keys to the constructor arguments. In this case I know I don't want the class name to be passed as an argument. I can remove it if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, let's keep it as it is then.

@lalinsky lalinsky merged commit e89bbb7 into master Sep 21, 2017
@lalinsky lalinsky deleted the sentinel-no-threds branch September 30, 2017 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants