예제 #1
0
 def flush(self):
     self.ready = True
     total_sent_bytes = 0
     try:
         while self.buffer_queue:
             sent_bytes = writev.writev(self.sock.fileno(),
                                          self.buffer_queue)
             total_sent_bytes += sent_bytes
             while (self.buffer_queue and sent_bytes and
                    len(self.buffer_queue[0]) <= sent_bytes):
                 sent_bytes -= len(self.buffer_queue.popleft())
             if sent_bytes:
                 # One of the buffers was partially sent
                 self.buffer_queue[0] = self.buffer_queue[0][sent_bytes:]
     except IOError, exc:
         if exc.errno == errno.EAGAIN:
             self.ready = False
         else:
             raise
예제 #2
0
 def test_written(self):
     buff = 'abcdef'
     self.assertEqual(len(buff), writev.writev(self.output.fileno(), buff))
     self.output.seek(0)
     self.assertEqual(buff, self.output.read())
예제 #3
0
파일: test_writev.py 프로젝트: xaiki/savate
 def test_written(self):
     buff = 'abcdef'
     self.assertEqual(len(buff), writev.writev(self.output.fileno(),
                                               buff))
     self.output.seek(0)
     self.assertEqual(buff, self.output.read())