@asyncio.coroutine<EOL><INDENT>def flush(self, timeout=<NUM_LIT>):<DEDENT>
if timeout <= <NUM_LIT:0>:<EOL><INDENT>raise ErrBadTimeout<EOL><DEDENT>if self.is_closed:<EOL><INDENT>raise ErrConnectionClosed<EOL><DEDENT>future = asyncio.Future(loop=self._loop)<EOL>try:<EOL><INDENT>yield from self._send_ping(future)<EOL>yield from asyncio.wait_for(future, timeout, loop=self._loop)<EOL><DEDENT>except asyncio.TimeoutError:<EOL><INDENT>future.cancel()<EOL>raise ErrTimeout<EOL><DEDENT>
Sends a ping to the server expecting a pong back ensuring
what we have written so far has made it to the server and
also enabling measuring of roundtrip time.
In case a pong is not returned within the allowed timeout,
then it will raise ErrTimeout.