twisted 一些test

 

 

 

 

class Countdown(object):

    counter = 5

    def count(self):
        if self.counter == 0:
            reactor.stop()
        else:
            print (self.counter, '...')
            self.counter -= 1
            reactor.callLater(1, self.count)

from twisted.internet import reactor

reactor.callWhenRunning(Countdown().count)

print ('Start!')
reactor.run()
print ('Stop!')

 

posted @ 2023-03-02 13:53  AngDH  阅读(11)  评论(0编辑  收藏  举报