Thanks for the assist, we ended up using something quite similar to this. I'm refactoring a portion of an app that was originally all in python, but now some functions were required to use the DB stored procedures instead for compatibility, and they weren't designed to be used in Twisted-fashion! On to the next interesting Twisted problem.....<br>
Ken<br><br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">@inlineCallbacks must decorate only generator functions.<br>
<br>
Since 'yield' doesn't appear anywhere in the body of round_val (or, for that matter, round_per) this code will break in other ways. Allen Short's suggestion will fix your code because it added a 'yield', but you need to be aware of this issue in case there are other such functions in the future that don't actually handle any Deferreds.<br>
<br>
Also, inlineCallbacks adds some overhead, and really should only be used when the resulting code is easier to read. Personally, I think a simpler definition of round_val would be simply<br>
<div class="im"><br>
def round_val(id, value, rule):<br>
"""<br>
Return first element of round_value_and_percent<br>
"""<br>
</div> return round_value_and_percent(id, value, 0, rule).addCallback(<br>
lambda valueAndPercent: valueAndPercent[0]<br>
)<br>
<br>
no @inlineCallbacks required.<br>
<div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</div></div></blockquote></div><br>