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


Python queue.Queue类代码示例

本文整理汇总了Python中slimta.queue.Queue的典型用法代码示例。如果您正苦于以下问题:Python Queue类的具体用法?Python Queue怎么用?Python Queue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_load_all

 def test_load_all(self):
     self.store.load().AndReturn([(3, 'one'), (5, 'two'), (1, 'three')])
     self.mox.ReplayAll()
     queue = Queue(self.store, self.relay)
     queue._load_all()
     self.assertEqual([(1, 'three'), (3, 'one'), (5, 'two')], queue.queued)
     self.assertTrue(queue.wake.isSet())
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:7,代码来源:test_slimta_queue.py

示例2: test_check_ready_missing

 def test_check_ready_missing(self):
     self.store.get('1234').AndRaise(KeyError)
     self.mox.ReplayAll()
     queue = Queue(self.store, self.relay, store_pool=Pool(5))
     queue._add_queued((10, '1234'))
     queue._check_ready(20)
     queue.store_pool.join()
开发者ID:you4you4,项目名称:python-slimta,代码行数:7,代码来源:test_slimta_queue.py

示例3: test_load_all_empty

 def test_load_all_empty(self):
     self.store.load().AndReturn([])
     self.mox.ReplayAll()
     queue = Queue(self.store, self.relay)
     queue._load_all()
     self.assertEqual([], queue.queued)
     self.assertFalse(queue.wake.isSet())
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:7,代码来源:test_slimta_queue.py

示例4: test_enqueue_wait

 def test_enqueue_wait(self):
     self.store.write(self.env, IsA(float)).AndReturn('1234')
     self.relay._attempt(self.env, 0)
     self.store.remove('1234')
     self.mox.ReplayAll()
     queue = Queue(self.store, self.relay, relay_pool=5)
     self.assertEqual([(self.env, '1234')], queue.enqueue(self.env))
     queue.relay_pool.join()
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:8,代码来源:test_slimta_queue.py

示例5: test_check_ready

 def test_check_ready(self):
     self.store.get('1234').AndReturn((self.env, 0))
     self.relay._attempt(self.env, 0)
     self.store.remove('1234')
     self.mox.ReplayAll()
     queue = Queue(self.store, self.relay, store_pool=Pool(5))
     queue._add_queued((10, '1234'))
     queue._check_ready(20)
     queue.store_pool.join()
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:9,代码来源:test_slimta_queue.py

示例6: test_wait_ready_nonequeued

 def test_wait_ready_nonequeued(self):
     queue = Queue(self.store, self.relay)
     def wait_func():
         queue._wait_ready(20)
     thread = gevent.spawn(wait_func)
     gevent.sleep(0)
     self.assertFalse(thread.ready())
     queue._add_queued((10, '1234'))
     gevent.sleep(0)
     self.assertTrue(thread.ready())
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:10,代码来源:test_slimta_queue.py

示例7: test_enqueue_wait_permanentfail

 def test_enqueue_wait_permanentfail(self):
     self.store.write(self.env, IsA(float)).AndReturn('1234')
     self.relay._attempt(self.env, 0).AndRaise(PermanentRelayError('permanent', Reply('550', 'permanent')))
     self.store.remove('1234')
     self.mox.ReplayAll()
     def no_bounce(envelope, reply):
         return None
     queue = Queue(self.store, self.relay, bounce_factory=no_bounce, relay_pool=5)
     queue.enqueue(self.env)
     queue.relay_pool.join()
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:10,代码来源:test_slimta_queue.py

示例8: test_enqueue_wait_unhandledfail

 def test_enqueue_wait_unhandledfail(self):
     self.store.write(self.env, IsA(float)).AndReturn('1234')
     self.relay._attempt(self.env, 0).AndRaise(Exception('unhandled error'))
     self.store.increment_attempts('1234')
     self.store.set_timestamp('1234', IsA(float))
     self.mox.ReplayAll()
     def backoff(envelope, attempts):
         return 0
     queue = Queue(self.store, self.relay, backoff=backoff, relay_pool=5)
     queue.enqueue(self.env)
     queue.relay_pool.join()
开发者ID:rafaelnovello,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_queue.py

示例9: test_enqueue_wait_transientfail

 def test_enqueue_wait_transientfail(self):
     self.store.write(self.env, IsA(float)).AndReturn('1234')
     self.relay._attempt(self.env, 0).AndRaise(TransientRelayError('transient', Reply('450', 'transient')))
     self.store.increment_attempts('1234')
     self.store.set_timestamp('1234', IsA(float))
     self.mox.ReplayAll()
     def backoff(envelope, attempts):
         return 0
     queue = Queue(self.store, self.relay, backoff=backoff, relay_pool=5)
     queue.enqueue(self.env)
     queue.relay_pool.join()
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_queue.py

示例10: test_wait_store

 def test_wait_store(self):
     queue = Queue(self.store, self.relay, relay_pool=5)
     queue.wake = self.mox.CreateMock(AsyncResult)
     self.store.wait().AndReturn((1234567890, '1234'))
     queue.wake.set()
     self.store.wait().AndReturn(None)
     self.store.wait().AndReturn((2345678901, '5678'))
     queue.wake.set()
     self.store.wait().AndRaise(NotImplementedError)
     self.mox.ReplayAll()
     queue._wait_store()
开发者ID:pombredanne,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_queue.py

示例11: test_policies

 def test_policies(self):
     p1 = self.mox.CreateMock(QueuePolicy)
     p2 = self.mox.CreateMock(QueuePolicy)
     p1.apply(self.env)
     p2.apply(self.env)
     self.mox.ReplayAll()
     queue = Queue(self.store, self.relay)
     queue.add_policy(p1)
     queue.add_policy(p2)
     self.assertRaises(TypeError, queue.add_policy, None)
     queue._run_policies(self.env)
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_queue.py

示例12: test_add_queued

 def test_add_queued(self):
     queue = Queue(self.store, self.relay)
     queue._add_queued((10, 'one'))
     queue._add_queued((5, 'two'))
     queue._add_queued((99, 'one'))
     queue._add_queued((7, 'three'))
     self.assertEqual([(5, 'two'), (7, 'three'), (10, 'one')], queue.queued)
     self.assertTrue(queue.wake.isSet())
开发者ID:pombredanne,项目名称:python-slimta,代码行数:8,代码来源:test_slimta_queue.py

示例13: test_wait_ready_noneready

 def test_wait_ready_noneready(self):
     queue = Queue(self.store, self.relay)
     queue._add_queued((20, '1234'))
     queue.wake.clear()
     def wait_func():
         queue._wait_ready(10)
     thread = gevent.spawn(wait_func)
     gevent.sleep(0)
     self.assertFalse(thread.ready())
     queue._add_queued((5, '5678'))
     gevent.sleep(0)
     self.assertTrue(thread.ready())
开发者ID:pombredanne,项目名称:python-slimta,代码行数:12,代码来源:test_slimta_queue.py

示例14: test_enqueue_wait_splitpolicy

 def test_enqueue_wait_splitpolicy(self):
     splitpolicy1 = self.mox.CreateMock(QueuePolicy)
     splitpolicy2 = self.mox.CreateMock(QueuePolicy)
     regpolicy = self.mox.CreateMock(QueuePolicy)
     env1 = Envelope('[email protected]', ['[email protected]'])
     env2 = Envelope('[email protected]', ['[email protected]'])
     env3 = Envelope('[email protected]', ['[email protected]'])
     splitpolicy1.apply(self.env).AndReturn([env1, env2])
     regpolicy.apply(env1)
     splitpolicy2.apply(env1)
     regpolicy.apply(env2)
     splitpolicy2.apply(env2).AndReturn([env2, env3])
     self.store.write(env1, IsA(float)).AndReturn('1234')
     self.store.write(env2, IsA(float)).AndReturn('5678')
     self.store.write(env3, IsA(float)).AndReturn('90AB')
     self.relay._attempt(env1, 0).InAnyOrder('relay')
     self.relay._attempt(env2, 0).InAnyOrder('relay')
     self.relay._attempt(env3, 0).InAnyOrder('relay')
     self.store.remove('1234').InAnyOrder('relay')
     self.store.remove('5678').InAnyOrder('relay')
     self.store.remove('90AB').InAnyOrder('relay')
     self.mox.ReplayAll()
     queue = Queue(self.store, self.relay, relay_pool=5)
     queue.add_policy(splitpolicy1)
     queue.add_policy(regpolicy)
     queue.add_policy(splitpolicy2)
     self.assertEqual([(env1, '1234'), (env2, '5678'), (env3, '90AB')],
                      queue.enqueue(self.env))
     queue.relay_pool.join()
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:29,代码来源:test_slimta_queue.py

示例15: test_enqueue_wait_partial_relay_expired

 def test_enqueue_wait_partial_relay_expired(self):
     env = Envelope('[email protected]', ['[email protected]',
                                           '[email protected]',
                                           '[email protected]'])
     bounce_mock = self.mox.CreateMockAnything()
     bounce_mock(IsA(Envelope), IsA(Reply)).AndReturn(None)
     bounce_mock(IsA(Envelope), IsA(Reply)).AndReturn(None)
     self.store.write(env, IsA(float)).AndReturn('1234')
     self.relay._attempt(env, 0).AndReturn([TransientRelayError('transient', Reply('450', 'transient 1')),
                                            TransientRelayError('transient', Reply('450', 'transient 1')),
                                            TransientRelayError('transient', Reply('450', 'transient 2'))])
     self.store.increment_attempts('1234')
     self.store.remove('1234')
     self.mox.ReplayAll()
     queue = Queue(self.store, self.relay, bounce_factory=bounce_mock, relay_pool=5)
     queue.enqueue(env)
     queue.relay_pool.join()
开发者ID:sk1p,项目名称:python-slimta,代码行数:17,代码来源:test_slimta_queue.py


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