def roundtrip_until_done(sender, receiver):
    """
    Send datagrams from `sender` to `receiver` and back
    repeatedly until no more datagrams are exchanged.
    """
    rounds = 0
    while roundtrip(sender, receiver) != (0, 0):
        rounds += 1
        assert rounds < 10, "Too many roundtrips!"

    Send datagrams from `sender` to `receiver` and back
    repeatedly until no more datagrams are exchanged.
    
tests/test_connection.py