"Event loop closed" with asyncio/asyncpg
I clearly have a fundamental misunderstanding of how async works. In Python 3.14, this snipped:
import asyncio
import asyncpg
def adapted_async():
conn = asyncio.run(asyncpg.connect(database='async_test'))
asyncio.run(conn.close())
if \__name_\_ == "\__main_\_":
adapted_async()
... results in RuntimeError: Event loop is closed. My understanding was that asyncio.run() created a new event loop on each invocation, but clearly my understanding was wrong. What is the correct way of doing this?
(This is a purely synthetic example, of course.)