I recently added nest-asyncio to a project that usesasyncio-atexit and it seems to break it. Do you have any thoughts on how I could use both together?
Minimal reproducible example
Before
# mre.py
import asyncio
import asyncio_atexit
async def finalizer():
print("running finalizer")
async def main():
asyncio_atexit.register(finalizer)
if __name__ == "__main__":
print("before")
asyncio.run(main())
print("after")
$ python mre.py
before
running finalizer
after
After
# mre.py
import asyncio
import asyncio_atexit
+ import nest_asyncio
+ nest_asyncio.apply()
async def finalizer():
print("running finalizer")
async def main():
asyncio_atexit.register(finalizer)
if __name__ == "__main__":
print("before")
asyncio.run(main())
print("after")
$ python mre.py
before
after
I recently added
nest-asyncioto a project that usesasyncio-atexitand it seems to break it. Do you have any thoughts on how I could use both together?Minimal reproducible example
Before
After