I was attempting to trigger twisted memcache calls from getattribute and return values to my objects. Is this possible ? My thinking was that gatherResults waits for the call to succeed or fail and then returns the results - which it does but the interpreter returns a deferred to whatever is accessing the attribute.
def __getattribute__(self, key):
exempt = ['__providedBy__', '__class__', '__provides__', '__dict__', 'uid']
if key in exempt:
return object.__getattribute__(self, key)
else:
print key
addr = IPv4Address('TCP', '127.0.0.1', 11211)
mc_pool = MemCachePool(addr, maxClients=10)
uid = object.__getattribute__(self, key)
def return_res(res):
return res
deferred_calls = [mc_pool.get(key)]
d = defer.gatherResults(deferred_calls, consumeErrors = True)
d.addCallback(return_res)