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

redis-py 2.10 changed "errors" connection keyword argument to "encoding_errors" #40

Closed
m-martinez opened this issue Jun 10, 2014 · 5 comments

Comments

@m-martinez
Copy link

The latest version of redis-py changed the keyword argument "errors" to "encoding_errorrs" resulting in the following error message when attempting to use request.session

Traceback (most recent call last):
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/waitress/channel.py", line 337, in service
    task.service()
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/waitress/task.py", line 173, in service
    self.execute()
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/waitress/task.py", line 392, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid/router.py", line 242, in __call__
    response = self.invoke_subrequest(request, use_tweens=True)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid/router.py", line 217, in invoke_subrequest
    response = handle_request(request)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid_debugtoolbar/toolbar.py", line 165, in toolbar_tween
    return handler(request)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid/tweens.py", line 21, in excview_tween
    response = handler(request)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid/router.py", line 163, in handle_request
    response = view_callable(context, request)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid/config/views.py", line 355, in rendered_view
    result = view(context, request)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid/config/views.py", line 501, in _requestonly_view
    response = view(request)
  File "/home/mmartinez/test/test/views.py", line 6, in my_view
    request.session
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid/decorator.py", line 37, in __get__
    val = self.wrapped(inst)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid/request.py", line 200, in session
    return factory(self)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/pyramid_redis_sessions/__init__.py", line 225, in factory
    is_new_session = redis.get(session_id) is None
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/redis/client.py", line 807, in get
    return self.execute_command('GET', name)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/redis/client.py", line 526, in execute_command
    connection = pool.get_connection(command_name, **options)
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/redis/connection.py", line 819, in get_connection
    connection = self.make_connection()
  File "/home/mmartinez/env/sandbox/lib/python2.7/site-packages/redis/connection.py", line 828, in make_connection
    return self.connection_class(**self.connection_kwargs)
TypeError: __init__() got an unexpected keyword argument 'errors'
omidraha added a commit to omidraha/pyramid_redis_sessions that referenced this issue Jun 16, 2014
@ericrasmussen
Copy link
Owner

Thanks for reporting! Going to pull in changes by @omidraha and test a couple different versions. Closing this one but you can follow activity on the master branch today/this weekend if interested.

@ericrasmussen
Copy link
Owner

OK, tested this and was not able to reproduce. If you look at redis-py's latest master, it shows StrictRedis still uses the kwarg errors, not encoding_errors:

https://github.com/andymccurdy/redis-py/blob/dffc6f97ce5cce454c07006e03b70c4cf41348bd/redis/client.py#L391

It uses encoding_errors internally (in its connection object), but the API exposed by StrictRedis is errors. I tested using errors on both redis-py 2.7 and 2.10 with no issues.

Were you using the default redis callable or a custom one? I can't think of anyway you could get that error unless you had a setting for redis.sessions.client_callable that used a different API than StrictRedis.

If you were not using a custom callable, can you share your redis session settings (minus secrets/cookie stuff/anything confidential) and the exact redis-py/pyramid/pyramid_redis_sessions versions?

I'll re-open while I wait to hear back. Thanks!

@ericrasmussen ericrasmussen reopened this Jul 3, 2014
@ericrasmussen
Copy link
Owner

Good news! I reproduced the error. Looks like a bug in redis-py to me, since they only document one API for StrictRedis regardless of how you invoke it, but the behavior differs when you use __init__ vs from_url. I opened an issue over on redis-py:

redis/redis-py#510

I'm going to figure out the latest working version of redis-py and pin it to that for now. I don't want to make code changes to accommodate two different APIs if it's just a bug they introduced on this version.

@ericrasmussen
Copy link
Owner

Going to close for now since PR #42 addresses this, but I'll follow the issue on the redis-py side. You can run "pip install redis==2.9.1 --upgrade" in your virtualenv until I hear back from them and see if they're going to treat it as a bug or update their docs for the changed API.

@m-martinez
Copy link
Author

Thank you so much for looking into it! I apologize for leaving you hanging the last couple of days, but it looks like you got to the bottom of it. I've set my project requirements to redis==2.9.1 for the time being.

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

No branches or pull requests

2 participants