def flush(self, debug=False):
        """
        Pump until there is no more input or output.

        Returns whether any data was moved.
        """
        result = False
        for x in range(1000):
            if self.pump(debug):
                result = True
            else:
                break
        else:
            assert 0, "Too long"
        return result

        Pump until there is no more input or output.

        Returns whether any data was moved.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/iosim.py