Skip to content

Releases: Chaoses-Ib/nest-asyncio2

nest-asyncio2 v1.7.1

20 Nov 20:48

Choose a tag to compare

  • apply() will set asyncio._nest_asyncio2 to help distinguish from patches made by nest_asyncio (#1)

  • apply() will warn if asyncio is already patched by nest_asyncio on Python 3.12+ (#1)

    You can also set error_on_mispatched=True to turn the warning into a RuntimeError, regardless of the Python version.

nest-asyncio2 v1.6.3

20 Nov 13:57

Choose a tag to compare

Leaked loop

Tip

TL;DR: Usually you don't need to worry about this. The biggest side effect is a ResourceWarning: unclosed event loop at exit on Python 3.12+ that is hidden by default.

If there is no existing event loop, patched asyncio.run() will create one but not close it afterwards. It will be reused later, so there will be at most one leaked loop.

asyncio.run() will always create and close the loop. But nest_asyncio (by accident or intentionally) missed it. As changing this behavior will break existing projects (e.g. ComfyScript, pyvista), nest-asyncio2 follows this behavior.

This will cause a ResourceWarning: unclosed event loop at exit on Python 3.12+, although it is hidden by default. (Note that if you call asyncio.get_event_loop() on the main thread without setting the loop before,
ResourceWarning is expected on Python 3.12~3.13, not caused by nest-asyncio2.)

If you want to follow asyncio.run()'s behavior and get rid of the ResourceWarning, you can set run_close_loop=True for all apply():

nest_asyncio2.apply(run_close_loop=True)

Or pass loop_factory to asyncio.run() on Python 3.12+:

asyncio.run(..., loop_factory=asyncio.new_event_loop)

nest-asyncio2 v2 may change run_close_loop to be enalbed by default.

nest-asyncio2 v1.6.2

19 Nov 13:16

Choose a tag to compare

  • fix: Python 3.14 get_event_loop_policy() deprecated warn (pyvista/pyvista#7938)
  • fix: unclosed event loop warn on Python 3.12+
  • feat: add aiohttp test and exmaple

nest-asyncio2 v1.6.1

18 Nov 16:04

Choose a tag to compare

nest-asyncio2 is a fork of the unmaintained nest_asyncio, with the following changes:

  • Python 3.12 loop_factory parameter support
  • Python 3.14 support (asyncio.current_task() and others are broken in nest_asyncio)

All interfaces are kept as they are. To migrate, you just need to change the package and module name to nest_asyncio2.