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

Added a warning when memcached client fails to store values too large #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions nagare/sessions/memcached_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import memcache

from nagare import local
from nagare import local, log
from nagare.sessions import ExpirationError, common
from nagare.sessions.serializer import Pickle

Expand Down Expand Up @@ -221,7 +221,14 @@ def store_state(self, session_id, state_id, secure_id, use_same_state, session_d
if not use_same_state:
self._get_connection().incr((KEY_PREFIX + 'state') % session_id)

self._get_connection().set_multi({
failures = self._get_connection().set_multi({
'sess': (secure_id, session_data),
'%05d' % state_id: state_data
}, self.ttl, KEY_PREFIX % session_id, self.min_compress_len)
if failures:
# Log and fail early
log.error(
'Failed to store keys %r in memcached, please check the size of your session or state (must be < %s bytes)' % (
failures,
self._get_connection().server_max_value_length))
raise ExpirationError() # FIXME: Create a new exception type?