当前位置: 首页>>代码示例>>Python>>正文


Python Hub.remove方法代码示例

本文整理汇总了Python中kombu.Hub.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Hub.remove方法的具体用法?Python Hub.remove怎么用?Python Hub.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kombu.Hub的用法示例。


在下文中一共展示了Hub.remove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_add_writers

# 需要导入模块: from kombu import Hub [as 别名]
# 或者: from kombu.Hub import remove [as 别名]
    def test_add_writers(self):
        hub = Hub()
        P = hub.poller = Mock()

        write_A = Mock()
        write_B = Mock()
        hub.add_writer(20, write_A)
        hub.add_writer(File(21), write_B)

        P.register.assert_has_calls([call(20, hub.WRITE), call(File(21), hub.WRITE)], any_order=True)

        self.assertEqual(hub.writers[20], (write_A, ()))
        self.assertEqual(hub.writers[21], (write_B, ()))

        hub.remove(20)
        self.assertNotIn(20, hub.writers)
        hub.remove(File(21))
        self.assertNotIn(21, hub.writers)
        P.unregister.assert_has_calls([call(20), call(21)])
开发者ID:NotSqrt,项目名称:celery,代码行数:21,代码来源:test_hub.py

示例2: test_add_remove_readers

# 需要导入模块: from kombu import Hub [as 别名]
# 或者: from kombu.Hub import remove [as 别名]
    def test_add_remove_readers(self):
        hub = Hub()
        P = hub.poller = Mock()

        read_A = Mock()
        read_B = Mock()
        hub.add_reader(10, read_A, 10)
        hub.add_reader(File(11), read_B, 11)

        P.register.assert_has_calls([call(10, hub.READ | hub.ERR), call(File(11), hub.READ | hub.ERR)], any_order=True)

        self.assertEqual(hub.readers[10], (read_A, (10,)))
        self.assertEqual(hub.readers[11], (read_B, (11,)))

        hub.remove(10)
        self.assertNotIn(10, hub.readers)
        hub.remove(File(11))
        self.assertNotIn(11, hub.readers)
        P.unregister.assert_has_calls([call(10), call(11)])
开发者ID:NotSqrt,项目名称:celery,代码行数:21,代码来源:test_hub.py

示例3: test_update_writers

# 需要导入模块: from kombu import Hub [as 别名]
# 或者: from kombu.Hub import remove [as 别名]
    def test_update_writers(self):
        hub = Hub()
        P = hub.poller = Mock()

        write_A = Mock()
        write_B = Mock()
        hub.update_writers({20: write_A, File(21): write_B})

        P.register.assert_has_calls([
            call(20, hub.WRITE),
            call(File(21), hub.WRITE),
        ], any_order=True)

        self.assertIs(hub.writers[20], write_A)
        self.assertIs(hub.writers[21], write_B)

        hub.remove(20)
        self.assertNotIn(20, hub.writers)
        hub.remove(File(21))
        self.assertNotIn(21, hub.writers)
        P.unregister.assert_has_calls([
            call(20), call(21),
        ])
开发者ID:jamesdear,项目名称:celery,代码行数:25,代码来源:test_hub.py

示例4: test_update_readers

# 需要导入模块: from kombu import Hub [as 别名]
# 或者: from kombu.Hub import remove [as 别名]
    def test_update_readers(self):
        hub = Hub()
        P = hub.poller = Mock()

        read_A = Mock()
        read_B = Mock()
        hub.update_readers({10: read_A, File(11): read_B})

        P.register.assert_has_calls([
            call(10, hub.READ | hub.ERR),
            call(File(11), hub.READ | hub.ERR),
        ], any_order=True)

        self.assertIs(hub.readers[10], read_A)
        self.assertIs(hub.readers[11], read_B)

        hub.remove(10)
        self.assertNotIn(10, hub.readers)
        hub.remove(File(11))
        self.assertNotIn(11, hub.readers)
        P.unregister.assert_has_calls([
            call(10), call(11),
        ])
开发者ID:jamesdear,项目名称:celery,代码行数:25,代码来源:test_hub.py

示例5: test_remove__unregister_raises

# 需要导入模块: from kombu import Hub [as 别名]
# 或者: from kombu.Hub import remove [as 别名]
    def test_remove__unregister_raises(self):
        hub = Hub()
        hub.poller = Mock()
        hub.poller.unregister.side_effect = OSError()

        hub.remove(313)
开发者ID:NotSqrt,项目名称:celery,代码行数:8,代码来源:test_hub.py

示例6: test_can_remove_unknown_fds

# 需要导入模块: from kombu import Hub [as 别名]
# 或者: from kombu.Hub import remove [as 别名]
 def test_can_remove_unknown_fds(self):
     hub = Hub()
     hub.poller = Mock()
     hub.remove(30)
     hub.remove(File(301))
开发者ID:NotSqrt,项目名称:celery,代码行数:7,代码来源:test_hub.py

示例7: test_Hub

# 需要导入模块: from kombu import Hub [as 别名]
# 或者: from kombu.Hub import remove [as 别名]

#.........这里部分代码省略.........
        self.hub.scheduler = iter([(0, eback)])
        with patch('kombu.async.hub.logger') as logger:
            with self.assertRaises(StopIteration):
                self.hub.fire_timers()
            self.assertTrue(logger.error.called)

        eback.side_effect = MemoryError('foo')
        self.hub.scheduler = iter([(0, eback)])
        with self.assertRaises(MemoryError):
            self.hub.fire_timers()

        eback.side_effect = OSError()
        eback.side_effect.errno = errno.ENOMEM
        self.hub.scheduler = iter([(0, eback)])
        with self.assertRaises(OSError):
            self.hub.fire_timers()

        eback.side_effect = OSError()
        eback.side_effect.errno = errno.ENOENT
        self.hub.scheduler = iter([(0, eback)])
        with patch('kombu.async.hub.logger') as logger:
            with self.assertRaises(StopIteration):
                self.hub.fire_timers()
            self.assertTrue(logger.error.called)

    def test_add_raises_ValueError(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.poller.register.side_effect = ValueError()
        self.hub._discard = Mock(name='hub.discard')
        with self.assertRaises(ValueError):
            self.hub.add(2, Mock(), READ)
        self.hub._discard.assert_called_with(2)

    def test_remove_reader(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.add(2, Mock(), READ)
        self.hub.add(2, Mock(), WRITE)
        self.hub.remove_reader(2)
        self.assertNotIn(2, self.hub.readers)
        self.assertIn(2, self.hub.writers)

    def test_remove_writer(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.add(2, Mock(), READ)
        self.hub.add(2, Mock(), WRITE)
        self.hub.remove_writer(2)
        self.assertIn(2, self.hub.readers)
        self.assertNotIn(2, self.hub.writers)

    def test_add__consolidate(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.add(2, Mock(), WRITE, consolidate=True)
        self.assertIn(2, self.hub.consolidate)
        self.assertIsNone(self.hub.writers[2])

    @patch('kombu.async.hub.logger')
    def test_on_callback_error(self, logger):
        self.hub.on_callback_error(Mock(name='callback'), KeyError())
        self.assertTrue(logger.error.called)

    def test_loop_property(self):
        self.hub._loop = None
        self.hub.create_loop = Mock(name='hub.create_loop')
        self.assertIs(self.hub.loop, self.hub.create_loop())
        self.assertIs(self.hub._loop, self.hub.create_loop())
开发者ID:megwill4268,项目名称:kombu,代码行数:69,代码来源:test_hub.py

示例8: setup

# 需要导入模块: from kombu import Hub [as 别名]
# 或者: from kombu.Hub import remove [as 别名]

#.........这里部分代码省略.........
        self.hub.scheduler = iter([(0, eback)])
        with patch('kombu.async.hub.logger') as logger:
            with pytest.raises(StopIteration):
                self.hub.fire_timers()
            logger.error.assert_called()

        eback.side_effect = MemoryError('foo')
        self.hub.scheduler = iter([(0, eback)])
        with pytest.raises(MemoryError):
            self.hub.fire_timers()

        eback.side_effect = OSError()
        eback.side_effect.errno = errno.ENOMEM
        self.hub.scheduler = iter([(0, eback)])
        with pytest.raises(OSError):
            self.hub.fire_timers()

        eback.side_effect = OSError()
        eback.side_effect.errno = errno.ENOENT
        self.hub.scheduler = iter([(0, eback)])
        with patch('kombu.async.hub.logger') as logger:
            with pytest.raises(StopIteration):
                self.hub.fire_timers()
            logger.error.assert_called()

    def test_add_raises_ValueError(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.poller.register.side_effect = ValueError()
        self.hub._discard = Mock(name='hub.discard')
        with pytest.raises(ValueError):
            self.hub.add(2, Mock(), READ)
        self.hub._discard.assert_called_with(2)

    def test_remove_reader(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.add(2, Mock(), READ)
        self.hub.add(2, Mock(), WRITE)
        self.hub.remove_reader(2)
        assert 2 not in self.hub.readers
        assert 2 in self.hub.writers

    def test_remove_reader__not_writeable(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.add(2, Mock(), READ)
        self.hub.remove_reader(2)
        assert 2 not in self.hub.readers

    def test_remove_writer(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.add(2, Mock(), READ)
        self.hub.add(2, Mock(), WRITE)
        self.hub.remove_writer(2)
        assert 2 in self.hub.readers
        assert 2 not in self.hub.writers

    def test_remove_writer__not_readable(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.add(2, Mock(), WRITE)
        self.hub.remove_writer(2)
        assert 2 not in self.hub.writers

    def test_add__consolidate(self):
        self.hub.poller = Mock(name='hub.poller')
        self.hub.add(2, Mock(), WRITE, consolidate=True)
        assert 2 in self.hub.consolidate
        assert self.hub.writers[2] is None
开发者ID:Erve1879,项目名称:kombu,代码行数:70,代码来源:test_hub.py


注:本文中的kombu.Hub.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。