Exemple #1
0
    def test_cancel_handler(self):
        """
        _cancel_handler() requeues objects in _canceled_objs
        """
        block = DummyProcessBlock()
        for obj in range(10):
            block.objs.put(obj)

        # Cancel the block
        block.events["cancel"].set()
        block._cancel_handler()

        # Order is not guaranteed
        self.assertCountEqual(block._canceled_objs, range(10))
Exemple #2
0
    def test_cancel_stopped_block(self):
        """
        _cancel_handler() clears the cancel and the stop event

        There also is an 'end object' tailed to _canceled_objs
        """
        block = DummyProcessBlock()
        block.events["stop"].set()

        # Cancel the block
        block.events["cancel"].set()
        block._cancel_handler()

        self.assertFalse(block.events["cancel"].is_set())
        self.assertFalse(block.events["stop"].is_set())
        self.assertIsNone(block._canceled_objs[-1])