Multiplex one TCP port to another

Hi! I need a Python server that multiplexes any incoming traffic on one TCP port to anyone listening on another port. Messages are newline-terminated, so on the incoming side the server should read one full line at the time and then broadcast that line to anyone connected on the receiving port. I believe I got this working using asyncio (see below), but I haven’t used Python in roughly a decade and I have never used asyncio, so I would be very grateful if anyone who spots any issues could point them out to me. Thanks!

import asyncio

MAX_QUEUE_SIZE = 128

async def main():
    receiving_server = await asyncio.start_server(receive, '127.0.0.1', 4444)
    sending_server = await asyncio.start_server( send, port = 4445)
    async with receiving_server:
        async with sending_server:
            await receiving_server.serve_forever()
            await sending_server.serve_forever()

class MessageQueue:
    def __init__(self):
        self.queue = []
        self.has_messages = asyncio.Event()

    def put(self, message):
        self.queue.append(message)
        self.has_messages.set()

    def pop_all(self):
        ret = self.queue
        self.queue = []
        self.has_messages.clear()
        return ret

message_queues = set()

async def receive(reader, _):
    global message_queues
    while True:
        message = await reader.readline()
        if message == b'': break
        message_queues = {
            queue
            for queue in message_queues
            if put_message(queue, message)
        }

def put_message(queue, message):
    queue.put(message)
    return len(queue.queue) <= MAX_QUEUE_SIZE

async def send(_, writer):
    queue = MessageQueue()
    message_queues.add(queue)
    try:
        while True:
            await queue.has_messages.wait()
            if not queue in message_queues: break
            if writer.is_closing():
                # asyncio seems to automatically close the writer once the
                # reader has been closed by the peer, and `writer.writelines()`
                # errors if called when the writer has already been closed.
                # This check ensures the below `writer.writelines()` does not
                # error.
                break
            writer.writelines(queue.pop_all())
            try:
                await writer.drain()
            except ConnectionError:
                break
    finally:
        writer.close()
        try:
            await writer.wait_closed()
        except ConnectionError:
            pass

asyncio.run(main())