'Pump until there is no more input or output.
Returns whether any data was moved.'

def flush(self, debug=False):

    result = False
    for x in range(1000):
        if self.pump(debug):
            result = True
        else:
            break
    else:
        assert 0, 'Too    long'
    return result
