Last active
February 10, 2016 16:51
-
-
Save jml/7c0d36b66ff92f0044f8 to your computer and use it in GitHub Desktop.
Deferred equivalent of sleep?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def waitFor(clock, delay, deferred): | |
""" | |
Usage:: | |
waitFor(reactor, 20, d).addCallback(print) | |
Will wait for 20s before calling ``print`` with the result of ``d``. | |
""" | |
# H/T @tomprince | |
return deferred.addCallback(lambda x: deferLater(clock, delay, lambda: x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment