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)
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)
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