Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Looping(object):
- active = 0
- def __init__(self, counter, which):
- self.counter = counter
- self.which = which
- self.delay = 0
- Looping.active += 1
- def __call__(self):
- if self.counter <= 0:
- print "Finished" , self.which
- Looping.active -= 1
- if Looping.active <= 0:
- reactor.stop()
- else:
- print self.counter, self.which, "..."
- self.counter -= 1
- from twisted.internet.task import LoopingCall
- from twisted.internet import reactor
- print "Start"
- LoopingCall(Looping(5, "First")).start(2)
- LoopingCall(Looping(5, "Second")).start(1)
- LoopingCall(Looping(5, "Third")).start(0.5)
- reactor.run()
- print "Stop"
Advertisement
Add Comment
Please, Sign In to add comment