from twisted.internet import reactor这里reactor默认为 selectreactor
若要选择其他类型的reactor则
from twisted.internet import pollreactor
pollreactor.install()
我们得用Twisted来做什么吧。下面这段代码在reactor循环开始后向终端打印一条消息:
def hello():
print 'Hello from the reactor loop!'
print 'Lately I feel like I\'m stuck in a rut.'
from twisted.internet import reactor
reactor.callWhenRunning(hello)
print 'Starting the reactor.'
reactor.run()