<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote cite="mid:19574.17828.236399.757022@jon.es" type="cite">
<pre wrap="">Yes, I was expecting you to wrap item.obsolete() and renew(data) in
try/except, as needed. If you want a clean but slightly slower way to do
that, how about something like:
def getCachedResult(cache, key):
def release(result, item):
item.release()
return result
def renew(data):
return renew(data)
def notFound(fail):
fail.trap(NotFound)
def readItem(item):
return item.read()
def checkObsolete(item):
d = defer.maybeDeferred(item.obsolete)
d.addCallback(lambda _: readItem(item))
d.addBoth(release, item)
d.addCallback(renew)
return d
d = cache.open(key)
d.addCallbacks(checkObsolete, notFound)
return d
</pre>
</blockquote>
Thanks, maybeDeferred<span id="result_box" class="short_text"><span
style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);"
title=""> </span></span><span id="result_box" class="short_text"><span
style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);"
title="">is what I missed</span></span><span id="result_box"
class="short_text"><span
style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);"
title=""> :)<br>
</span></span>
</body>
</html>