Example #1
0
class _PollsHandler(object):
    """
    Handler for the signals
    from the Polls Model
    """

    def __init__(self, func, *args):
        self.looping_call = LoopingCall(func, *args)

    def post_save_cb(self, sender, **kwargs):
        poll = kwargs["instance"]
        self.looping_call.start(poll.period)

    def post_delete_cb(self, sender, **kwargs):
        self.looping_call.stop()
Example #2
0
 def test_looping_call(self):
     self.total = 0
     def foo(arg):
         self.total += arg
     p = LoopingCall(foo, 1)
     p.start(0.1)
     time.sleep(1)
     p.stop()
     self.assertEquals(9, self.total)
     time.sleep(1)
     self.assertEquals(9, self.total)        
     p.start(0.4)
     time.sleep(1)
     p.stop()
     self.assertEquals(11, self.total)
Example #3
0
 def __init__(self, func, *args):
     self.looping_call = LoopingCall(func, *args)