Created
December 10, 2010 00:51
-
-
Save theduderog/735597 to your computer and use it in GitHub Desktop.
Like any decorator, you can use timeout with the @timeout(secs) syntax or manually pass in a function to wrap
This file contains hidden or 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
from twisted.internet import defer, reactor | |
@defer.inlineCallbacks | |
def main(): | |
client = Client() | |
foo_with_timeout = timeout(5)(client.foo) | |
try: | |
result = yield foo_with_timeout(x=1, y=2) | |
finally: | |
reactor.stop() | |
print result | |
main() | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment