Last active
August 29, 2015 14:28
-
-
Save rystsov/3e74988da0e09138a7ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def put(self, test, val, timeout): | |
due = now() + timeout | |
while due > now(): | |
result = self._read_write_read(test, val, due) | |
if isinstance(result, NetworkError): continue | |
return result # OK or Conflict | |
return NetworkError() | |
def get(self, timeout): | |
return self.put(None, None, timeout) | |
def set_q(self, q): | |
return self._epic_change( | |
lambda state: state.q==q, | |
lambda state: state.q=q | |
) | |
def add_node(self, node): | |
return self._epic_change( | |
lambda state: node in state.nodes, | |
lambda state: state.nodes.append(node) | |
) | |
def rm_node(self, node): | |
return self._epic_change( | |
lambda state: node not in state.nodes, | |
lambda state: state.nodes.rm(node) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment