code: def _write_fragments(self, fragments):
          
          answer = tornado.gen.Future()
  
          if not fragments:
              answer.set_result(None)
              return answer
  
          io_loop = IOLoop.current()
  
          def _write_fragment(future):
              if future and future.exception():
                  return answer.set_exc_info(future.exc_info())
  
              try:
                  fragment = fragments.next()
              except StopIteration:
                  return answer.set_result(None)
  
              io_loop.add_future(self.writer.put(fragment), _write_fragment)
  
          _write_fragment(None)
          return answer
docs: :param fragments:
              A generator of messages