[Twisted-Python] help with Deferreds
    Sergey Magafurov 
    smagafurov at naumen.ru
       
    Thu Aug 26 03:47:39 MDT 2010
    
    
  
How to rewrite this regular function with Deferred-style?
def getCachedResult(cache, key):
     try:
         item = cache.open(key)
     except NotFound:
         return None
     try:
         if item.obsolete():
             return None
         data = item.read()
     finally:
         item.release()
     result = renew(data)
     return result
Conditions:
1. 'cache.open' and 'item.read' become deffered
2. 'item.obsolete()' and 'renew(data)' are not deferred
    
    
More information about the Twisted-Python
mailing list