How to set number of calls of the function scheduled by LoopingCall?

Viewed 508

Here is the skeleton of the code:

from twisted.internet import reactor
from twisted.internet.task import LoopingCall

def do_something():
    print "Doing something..."

def process_result():
    print "Processing result..."

def loop():
    LoopingCall(do_something).start(1)

reactor.callWhenRunning(loop)
reactor.run()

In my code I want to run do_something for 100 times, and after that I will call process_result to do what its name indicates.

In the documentation I found a withCount, however I was confused about "which should have occurred since it was last invoked" and "The count is normally 1" in it. (Using LoopingCall to call a function once? What's the point? I think I misunderstood it but what is the correct explanation?)

I'd like to know: is withCount the correct thing to use? If yes, can someone provide a concrete example?

1 Answers
Related