def handler(bf: PacketButterfly): while True: echopacket = yield from bf.read() if not echopacket: break bf.write(echopacket)