Skip to content

Breaks with nest-asyncio #3

Description

@jacobtomlinson

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions