<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Brian<br>
<br>
Forgive me for butting in, but.... why :-)<br>
<br></blockquote><div><br>Helpful butting in is more than fine..<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Importing the reactor is no big deal, and if you use task.deferLater, apart<br>
from not having to write any code you also have the advantage of being able<br>
to pass it a result that the deferred will be called with.<br>
<br>
For this reason you can also put a task.deferLater result into a callback<br>
chain to achieve an async sleep and it will duly pass the result along. E.g.:<br>
<br>
  from twisted.internet import reactor, task, defer<br>
<br>
  d = somethingReturningADeferred()<br>
  d.addCallback(lambda x: task.deferLater(reactor, 5.0, defer.passthru, x))<br>
<font color="#888888"><br></font></blockquote><div><br>Ahh, I see.  I saw the signature of deferLater and the Clock class in task and I thought that I would have<br>to create a Clock instance by hand.  That I can simply use the reactor (which of course is already imported and running in my code) simplifies the usage of deferLater.  Thanks!<br>
<br>But, even with this, I do like the flow and readability of code that uses sleep like this:<br><br>@inlineCallbacks<br>def f():<br>  result1 = yield somethingDeferred()<br>  yield sleep(1.0)<br>  result2 = yield anotherDeferred(result2)<br>
<br>Rather than the way that deferLater looks:<br><br>@inlineCallbacks<br>def f():<br>  result1 = yield somethingDeferred()<br>
  result2 = yield task.deferLater(reactor, 1.0, anotherDeferred, result2)<br><br>But, the difference at this point is entirely aesthetic.<br><br>One question though - can someone explain the need/usage cases for task.Clock and the other things in task?<br>
<br>Cheers,<br><br>Brian<br><br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font color="#888888">
Terry<br>
</font><div><div></div><div class="h5"><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>