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:
parent
0df6d848ea
commit
031f814612
|
@ -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():
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue