twisted 学习笔记一:事件循环

from twisted.internet import reactor

import time



def printTime():

    print "Current time is",time.strftime("%H:%M:%S")



def stopReactor():

    print "Stopping reactor"

    print "Current time is",time.strftime("%H:%M:%S")

    reactor.stop()



reactor.callLater(1, printTime)

reactor.callLater(2, printTime)

reactor.callLater(3, printTime)

reactor.callLater(4, printTime)

reactor.callLater(10, stopReactor)

print "Running the reactor..."

reactor.run()

print 'Reactor stopped'

  twisted 学习笔记一:事件循环

你可能感兴趣的:(学习笔记)