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


Python StablePriorityQueue.get方法代码示例

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


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

示例1: test_queue_length

# 需要导入模块: from awscli.customizations.s3.utils import StablePriorityQueue [as 别名]
# 或者: from awscli.customizations.s3.utils.StablePriorityQueue import get [as 别名]
    def test_queue_length(self):
        a = mock.Mock()
        a.PRIORITY = 5

        q = StablePriorityQueue(maxsize=10, max_priority=20)
        self.assertEqual(q.qsize(), 0)

        q.put(a)
        self.assertEqual(q.qsize(), 1)

        q.get()
        self.assertEqual(q.qsize(), 0)
开发者ID:aws,项目名称:aws-cli,代码行数:14,代码来源:test_utils.py

示例2: test_insert_max_priority_capped

# 需要导入模块: from awscli.customizations.s3.utils import StablePriorityQueue [as 别名]
# 或者: from awscli.customizations.s3.utils.StablePriorityQueue import get [as 别名]
    def test_insert_max_priority_capped(self):
        q = StablePriorityQueue(maxsize=10, max_priority=20)
        a = mock.Mock()
        a.PRIORITY = 100
        q.put(a)

        self.assertIs(q.get(), a)
开发者ID:aws,项目名称:aws-cli,代码行数:9,代码来源:test_utils.py

示例3: test_fifo_order_of_same_priorities

# 需要导入模块: from awscli.customizations.s3.utils import StablePriorityQueue [as 别名]
# 或者: from awscli.customizations.s3.utils.StablePriorityQueue import get [as 别名]
    def test_fifo_order_of_same_priorities(self):
        a = mock.Mock()
        a.PRIORITY = 5
        b = mock.Mock()
        b.PRIORITY = 5
        c = mock.Mock()
        c.PRIORITY = 1

        q = StablePriorityQueue(maxsize=10, max_priority=20)
        q.put(a)
        q.put(b)
        q.put(c)

        # First we should get c because it's the lowest priority.
        # We're using assertIs because we want the *exact* object.
        self.assertIs(q.get(), c)
        # Then a and b are the same priority, but we should get
        # a first because it was inserted first.
        self.assertIs(q.get(), a)
        self.assertIs(q.get(), b)
开发者ID:aws,项目名称:aws-cli,代码行数:22,代码来源:test_utils.py

示例4: test_priority_attr_is_missing

# 需要导入模块: from awscli.customizations.s3.utils import StablePriorityQueue [as 别名]
# 或者: from awscli.customizations.s3.utils.StablePriorityQueue import get [as 别名]
    def test_priority_attr_is_missing(self):
        # If priority attr is missing, we should add it
        # to the lowest priority.
        q = StablePriorityQueue(maxsize=10, max_priority=20)
        a = object()
        b = mock.Mock()
        b.PRIORITY = 5

        q.put(a)
        q.put(b)

        self.assertIs(q.get(), b)
        self.assertIs(q.get(), a)
开发者ID:aws,项目名称:aws-cli,代码行数:15,代码来源:test_utils.py

示例5: TestTaskOrdering

# 需要导入模块: from awscli.customizations.s3.utils import StablePriorityQueue [as 别名]
# 或者: from awscli.customizations.s3.utils.StablePriorityQueue import get [as 别名]
class TestTaskOrdering(unittest.TestCase):
    def setUp(self):
        self.q = StablePriorityQueue(maxsize=10, max_priority=20)

    def create_task(self):
        # We don't actually care about the arguments, we just want to test
        # the ordering of the tasks.
        return CreateLocalFileTask(None, None)

    def complete_task(self):
        return CompleteDownloadTask(None, None, None, None, None)

    def download_task(self):
        return DownloadPartTask(None, None, None, None, mock.Mock(), None, None)

    def shutdown_task(self, priority=None):
        return ShutdownThreadRequest(priority)

    def test_order_unchanged_in_same_priority(self):
        create = self.create_task()
        download = self.download_task()
        complete = self.complete_task()

        self.q.put(create)
        self.q.put(download)
        self.q.put(complete)

        self.assertIs(self.q.get(), create)
        self.assertIs(self.q.get(), download)
        self.assertIs(self.q.get(), complete)

    def test_multiple_tasks(self):
        create = self.create_task()
        download = self.download_task()
        complete = self.complete_task()

        create2 = self.create_task()
        download2 = self.download_task()
        complete2 = self.complete_task()

        self.q.put(create)
        self.q.put(download)
        self.q.put(complete)

        self.q.put(create2)
        self.q.put(download2)
        self.q.put(complete2)

        self.assertIs(self.q.get(), create)
        self.assertIs(self.q.get(), download)
        self.assertIs(self.q.get(), complete)

        self.assertIs(self.q.get(), create2)
        self.assertIs(self.q.get(), download2)
        self.assertIs(self.q.get(), complete2)

    def test_shutdown_tasks_are_last(self):
        create = self.create_task()
        download = self.download_task()
        complete = self.complete_task()
        shutdown = self.shutdown_task(priority=11)

        self.q.put(create)
        self.q.put(download)
        self.q.put(complete)
        self.q.put(shutdown)

        self.assertIs(self.q.get(), create)
        self.assertIs(self.q.get(), download)
        self.assertIs(self.q.get(), complete)
        self.assertIs(self.q.get(), shutdown)
开发者ID:hardiku,项目名称:aws-cli,代码行数:73,代码来源:test_tasks.py


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