send an email when updating the SpaceAI consistently fails
[saartuer.git] / waker.py
index 681de1b1af4985fe33e2d80ee6798e2844a43188..79eff81cd0f31e60a5c4216fae9d0f2f1e1b7d2e 100644 (file)
--- a/waker.py
+++ b/waker.py
@@ -12,17 +12,16 @@ class ToBeWoken:
                self.one_shot = one_shot
 
 class Waker():
-       def __init__(self, sm):
-               self._sm = sm
-               self._t = ThreadRepeater(self._wake, SLEEP_TIME, name="Waker")
+       def __init__(self):
                self._tobewokens = []
                self._tobewokens_lock = Lock()
+               self._t = ThreadRepeater(self._wake, SLEEP_TIME, name="Waker")
        
-       def register(f, time, one_shot = False):
+       def register(self, f, time, one_shot = False):
                '''Register a function which is called approximately every <time> seconds (or just once, if one_shot is True). f should return quickly, or it will delay the waker!'''
                time = max(time//SLEEP_TIME, 1)
                with self._tobewokens_lock:
-                       self._tobewokens.append(ToBeWoken(f, time, 0, one_shot))
+                       self._tobewokens.append(ToBeWoken(f, time, one_shot))
        
        def _wake(self):
                with self._tobewokens_lock: