(self)
Flush the write buffer.

        The intended use is to write

          w.write(data)
          await w.drain()
Flush the write buffer.
Flush the write buffer .
async def drain(self):
        """Flush the write buffer.

        The intended use is to write

          w.write(data)
          await w.drain()
        """
        if self._reader is not None:
            exc = self._reader.exception()
            if exc is not None:
                raise exc
        if self._transport.is_closing():
            # Wait for protocol.connection_lost() call
            # Raise connection closing error if any,
            # ConnectionResetError otherwise
            # Yield to the event loop so connection_lost() may be
            # called.  Without this, _drain_helper() would return
            # immediately, and code that calls
            #     write(...); await drain()
            # in a loop would never call connection_lost(), so it
            # would not see an error when the socket is closed.
            await sleep(0)
        await self._protocol._drain_helper()
async def drain ( self ) : if self . _reader is not None : exc = self . _reader . exception ( ) if exc is not None : raise exc if self . _transport . is_closing ( ) : # Wait for protocol.connection_lost() call # Raise connection closing error if any, # ConnectionResetError otherwise # Yield to the event loop so connection_lost() may be # called.  Without this, _drain_helper() would return # immediately, and code that calls #     write(...); await drain() # in a loop would never call connection_lost(), so it # would not see an error when the socket is closed. await sleep ( 0 ) await self . _protocol . _drain_helper ( )