X-Git-Url: https://git.ralfj.de/saartuer.git/blobdiff_plain/b4ca24f8e8708dbb26c2ddd20c90a36217cc322f..8fa0d3c2b93ded551a61f48e2c8701e5f2370b76:/waker.py?ds=inline diff --git a/waker.py b/waker.py index dc4627b..79eff81 100644 --- a/waker.py +++ b/waker.py @@ -1,10 +1,15 @@ from libtuer import ThreadRepeater -from collections import namedtuple from threading import Lock SLEEP_TIME = 0.5 -ToBeWoken = namedtuple('ToBeWoken','f period time_since_call one_shot') +class ToBeWoken: + '''a simple struct storing information about a to-be-woken function''' + def __init__(self, f, period, one_shot): + self.f = f + self.period = period + self.time_since_call = 0 + self.one_shot = one_shot class Waker(): def __init__(self): @@ -16,7 +21,7 @@ class Waker(): '''Register a function which is called approximately every