Don't convert to deferreds when not necessary

This commit is contained in:
Erik Johnston 2017-03-28 10:41:08 +01:00
parent f9b4bb05e0
commit 86780a8bc3
5 changed files with 12 additions and 8 deletions

View file

@ -341,7 +341,10 @@ class CacheDescriptor(_CacheDescriptorBase):
cache.set(cache_key, result_d, callback=invalidate_callback)
observer = result_d.observe()
return logcontext.make_deferred_yieldable(observer)
if isinstance(observer, defer.Deferred):
return logcontext.make_deferred_yieldable(observer)
else:
return observer
wrapped.invalidate = cache.invalidate
wrapped.invalidate_all = cache.invalidate_all