Standardize the async result subclasses

Move away from these subclasses exposing there properties
as publicly viewable and have them only expose the base
class functions as things that are publicly useable.

This also adjusts how the zookeeper async result had a usage
of camelcasing that didn't seem to fit in the other naming
conventions that tooz uses.

Change-Id: Iaa1dd3bb7b359b2dab14a8aeeab9f2e3e9cd8d29
This commit is contained in:
Joshua Harlow 2014-09-18 14:32:30 -07:00
parent 0df6d848ea
commit 031f814612
2 changed files with 12 additions and 13 deletions

View File

@ -361,10 +361,10 @@ class MemcachedAsyncResult(coordination.CoordAsyncResult):
"""
def __init__(self, result):
self.result = result
self._result = result
def get(self, timeout=0):
return self.result
return self._result
@staticmethod
def done():
@ -379,10 +379,10 @@ class MemcachedAsyncError(coordination.CoordAsyncResult):
"""
def __init__(self, error):
self.error = error
self._error = error
def get(self, timeout=0):
raise self.error
def get(self, timeout=10):
raise self._error
@staticmethod
def done():

View File

@ -368,14 +368,13 @@ class KazooDriver(BaseZooKeeperDriver):
class ZooAsyncResult(coordination.CoordAsyncResult):
def __init__(self, kazoo_async_result, handler, **kwargs):
self._kazoo_async_result = kazoo_async_result
self._handler = handler
self._kwargs = kwargs
def __init__(self, kazooAsyncResult, handler, **kwargs):
self.kazooAsyncResult = kazooAsyncResult
self.handler = handler
self.kwargs = kwargs
def get(self, timeout=15):
return self.handler(self.kazooAsyncResult, timeout, **self.kwargs)
def get(self, timeout=10):
return self._handler(self._kazoo_async_result, timeout, **self._kwargs)
def done(self):
return self.kazooAsyncResult.ready()
return self._kazoo_async_result.ready()