From 031f8146122a0b11f63b9b70ad6a590ea45431e8 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 18 Sep 2014 14:32:30 -0700 Subject: 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 --- tooz/drivers/memcached.py | 10 +++++----- tooz/drivers/zookeeper.py | 15 +++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tooz/drivers/memcached.py b/tooz/drivers/memcached.py index 54ad27e..b6c4740 100644 --- a/tooz/drivers/memcached.py +++ b/tooz/drivers/memcached.py @@ -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(): diff --git a/tooz/drivers/zookeeper.py b/tooz/drivers/zookeeper.py index de9be32..504ae04 100644 --- a/tooz/drivers/zookeeper.py +++ b/tooz/drivers/zookeeper.py @@ -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() -- cgit v1.2.1