def test_timer_cancellation(self): # Various lists for tracking callback stage timeout = .1 callback = TimerCallback(timeout) timer = self.create_timer(timeout, callback.invoke) timer.cancel() # Release context allow for timer thread to run. time.sleep(.2) # Assert that the cancellation was honored self.assertFalse(callback.was_invoked())
def test_timer_cancellation(self): """ Verify that timer cancellation is honored """ # Various lists for tracking callback stage timeout = .1 callback = TimerCallback(timeout) timer = GeventConnection.create_timer(timeout, callback.invoke) timer.cancel() # Release context allow for timer thread to run. time.sleep(.2) timer_manager = GeventConnection._timers # Assert that the cancellation was honored self.assertFalse(timer_manager._queue) self.assertFalse(timer_manager._new_timers) self.assertFalse(callback.was_invoked())
def test_timer_cancellation(self, *args): """ Verify that timer cancellation is honored """ # Various lists for tracking callback stage connection = twistedreactor.TwistedConnection('1.2.3.4', cql_version='3.0.1') timeout = .1 callback = TimerCallback(timeout) timer = connection.create_timer(timeout, callback.invoke) timer.cancel() # Release context allow for timer thread to run. time.sleep(.2) timer_manager = connection._loop._timers # Assert that the cancellation was honored self.assertFalse(timer_manager._queue) self.assertFalse(timer_manager._new_timers) self.assertFalse(callback.was_invoked())