from twisted.internet import reactor這裏reactor默認爲 selectreactor react
若要選擇其餘類型的reactor則 oop
from twisted.internet import pollreactor import
pollreactor.install() select
咱們得用Twisted來作什麼吧。下面這段代碼在reactor循環開始後向終端打印一條消息: 循環
def hello(): 終端
print 'Hello from the reactor loop!' im
print 'Lately I feel like I\'m stuck in a rut.' call
from twisted.internet import reactor loop
reactor.callWhenRunning(hello) 消息
print 'Starting the reactor.'
reactor.run()