Open SerGeRybakov opened 2 years ago
And I think that's it:
def main() -> None:
connection = await aio_pika.connect()
async with connection:
channel = await connection.channel()
...
asyncio.run(main())
Actually, __del__
creates the asyncio task with .close()
, but it's not a guarantee, cause event loop might be closed before.
I would like to use the
aio-pika
pre-defined methodsawait connection.close()
andawait channel.close()
on program finish. Withpika
I just put them into__del__
method and everyone's happy. But as long as__del__
can't be asynchronous, I'm not able to call them anywhere except__aexit__
(but it's not the solution).Help me find the way, please.