mosquito / aio-pika

AMQP 0.9 client designed for asyncio and humans.
https://aio-pika.readthedocs.org/
Apache License 2.0
1.18k stars 186 forks source link

Fix memory leaks on channel close #491

Closed mosquito closed 1 year ago

mosquito commented 1 year ago

Fixes #490

leaks_test.py

import asyncio
import logging

import aiomisc
from aiomisc.service.tracer import MemoryTracer
from aio_pika import connect_robust

async def main():
    logging.basicConfig(level=logging.DEBUG)

    counter = 0
    while True:
        connect = await connect_robust()
        channel = await connect.channel()
        await asyncio.sleep(0.001)
        await channel.close()
        await connect.close()
        counter += 1

        if not counter % 100:
            logging.info("%d Connections done", counter)

aiomisc.run(main(), MemoryTracer(), log_format="rich")