import sys from twisted.internet import reactor, defer from twisted.python import log log.startLogging(sys.stdout) @defer.inlineCallbacks def foo(): reactor.stop() reactor.callWhenRunning(foo) reactor.run()