예제 #1
0
 def test_consume_queue(self):
     x = Queue()
     it = consume_queue(x)
     self.assertRaises(StopIteration, it.next)
     x.put("foo")
     it = consume_queue(x)
     self.assertEquals(it.next(), "foo")
     self.assertRaises(StopIteration, it.next)
예제 #2
0
 def test_consume_queue(self):
     x = Queue()
     it = consume_queue(x)
     self.assertRaises(StopIteration, it.next)
     x.put("foo")
     it = consume_queue(x)
     self.assertEqual(it.next(), "foo")
     self.assertRaises(StopIteration, it.next)
예제 #3
0
파일: batches.py 프로젝트: colinhowe/celery
 def _do_flush(self):
     self.debug("Wake-up to flush buffer...")
     requests = None
     if self._buffer.qsize():
         requests = list(consume_queue(self._buffer))
         if requests:
             self.debug("Buffer complete: %s" % (len(requests), ))
             self.flush(requests)
     if not requests:
         self.debug("Cancelling timer: Nothing in buffer.")
         self._tref.cancel()  # cancel timer.
         self._tref = None
예제 #4
0
 def _do_flush(self):
     self.debug("Wake-up to flush buffer...")
     requests = None
     if self._buffer.qsize():
         requests = list(consume_queue(self._buffer))
         if requests:
             self.debug("Buffer complete: %s" % (len(requests), ))
             self.flush(requests)
     if not requests:
         self.debug("Cancelling timer: Nothing in buffer.")
         self._tref.cancel()  # cancel timer.
         self._tref = None