Skip to content

Instantly share code, notes, and snippets.

@theduderog
Created December 10, 2010 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theduderog/735597 to your computer and use it in GitHub Desktop.
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
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