I'm not sure this is a good fit in the standard library. There's too much that the implementer might want to customize for their repeating needs. For your pinger, what if a ping fails? Keep pinging while it fails? Timeout for a bit and try again? Increasing timeouts? Just exit? I don't think there's a general enough use case that a repetitive timer has in order to be included.
The following will likely do what you want.
import threading
class RepeatTimer(threading.Thread):
def __init__(self, interval, callable, *args, **kwargs):
threading.Thread.__init__(self)
self.interval = interval
self.callable = callable
self.args = args
self.kwargs = kwargs
self.event = threading.Event()
self.event.set()
def run(self):
while self.event.is_set():
t = threading.Timer(self.interval, self.callable,
self.args, self.kwargs)
t.start()
t.join()
def cancel(self):
self.event.clear()