本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)