Ejemplo n.º 1
0
 def setUp(self):
     if EventletConnection is None:
         raise unittest.SkipTest("Eventlet libraries not available")
     if not is_eventlet_monkey_patched():
         raise unittest.SkipTest(
             "Can't test eventlet without monkey patching")
     EventletConnection.initialize_reactor()
Ejemplo n.º 2
0
 def setUpClass(cls):
     # This is run even though the class is skipped, so we need
     # to make sure no monkey patching is happening
     if not MONKEY_PATCH_LOOP:
         return
     monkey_patch()
     cls.connection_class = EventletConnection
     EventletConnection.initialize_reactor()
Ejemplo n.º 3
0
 def setUpClass(cls):
     # This is run even though the class is skipped, so we need
     # to make sure no monkey patching is happening
     if not MONKEY_PATCH_LOOP:
         return
     monkey_patch()
     cls.connection_class = EventletConnection
     EventletConnection.initialize_reactor()
Ejemplo n.º 4
0
    def setUpClass(cls):
        # This is run even though the class is skipped, so we need
        # to make sure no monkey patching is happening
        if not MONKEY_PATCH_LOOP:
            return

        # This is being added temporarily due to a bug in eventlet:
        # https://github.com/eventlet/eventlet/issues/401
        import eventlet; eventlet.sleep()
        monkey_patch()
        cls.connection_class = EventletConnection
        EventletConnection.initialize_reactor()
Ejemplo n.º 5
0
    def setUpClass(cls):
        # This is run even though the class is skipped, so we need
        # to make sure no monkey patching is happening
        if skip_condition:
            return

        # This is being added temporarily due to a bug in eventlet:
        # https://github.com/eventlet/eventlet/issues/401
        import eventlet
        eventlet.sleep()
        monkey_patch()
        # cls.connection_class = EventletConnection

        EventletConnection.initialize_reactor()
        assert EventletConnection._timers is not None
Ejemplo n.º 6
0
    def test_timer_cancellation(self):
        """
        Verify that timer cancellation is honored
        """

        # Various lists for tracking callback stage
        timeout = .1
        callback = TimerCallback(timeout)
        timer = EventletConnection.create_timer(timeout, callback.invoke)
        timer.cancel()
        # Release context allow for timer thread to run.
        time.sleep(.2)
        timer_manager = EventletConnection._timers
        # Assert that the cancellation was honored
        self.assertFalse(timer_manager._queue)
        self.assertFalse(timer_manager._new_timers)
        self.assertFalse(callback.was_invoked())
Ejemplo n.º 7
0
    def test_timer_cancellation(self):
        """
        Verify that timer cancellation is honored
        """

        # Various lists for tracking callback stage
        timeout = .1
        callback = TimerCallback(timeout)
        timer = EventletConnection.create_timer(timeout, callback.invoke)
        timer.cancel()
        # Release context allow for timer thread to run.
        time.sleep(.2)
        timer_manager = EventletConnection._timers
        # Assert that the cancellation was honored
        self.assertFalse(timer_manager._queue)
        self.assertFalse(timer_manager._new_timers)
        self.assertFalse(callback.was_invoked())
Ejemplo n.º 8
0
 def setUp(self):
     if EventletConnection is None:
         raise unittest.SkipTest("Eventlet libraries not available")
     if not is_eventlet_monkey_patched():
         raise unittest.SkipTest("Can't test eventlet without monkey patching")
     EventletConnection.initialize_reactor()