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

share deaduntils between hosts #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,9 @@ def check_key(self, key, key_extra_len=0):
"Control/space characters not allowed (key=%r)" % key)


_host_last_deaduntils = {}
Copy link
Owner

Choose a reason for hiding this comment

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

This never gets reset, once a host becomes alive should there be a "del _host_list_deaduntils[self.ip)"?

Copy link
Author

Choose a reason for hiding this comment

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

Glad to get your response, how about the new patch, I think maybe "_host_list_deaduntils[self.ip]=0" is better, which avoids KeyError.



class _Host(object):

def __init__(self, host, debug=0, dead_retry=_DEAD_RETRY,
Expand Down Expand Up @@ -1371,7 +1374,7 @@ def __init__(self, host, debug=0, dead_retry=_DEAD_RETRY,
self.port = int(hostData.get('port') or 11211)
self.address = (self.ip, self.port)

self.deaduntil = 0
self.deaduntil = _host_last_deaduntils.get(self.ip, 0)
self.socket = None
self.flush_on_next_connect = 0

Expand Down Expand Up @@ -1411,6 +1414,7 @@ def _get_socket(self):
s.connect(self.address)
except socket.timeout as msg:
self.mark_dead("connect: %s" % msg)
_host_last_deaduntils[self.ip] = self.deaduntil
return None
except socket.error as msg:
if isinstance(msg, tuple):
Expand Down