Releases: Chaoses-Ib/nest-asyncio2
nest-asyncio2 v1.7.1
-
apply()will setasyncio._nest_asyncio2to help distinguish from patches made bynest_asyncio(#1) -
apply()will warn if asyncio is already patched bynest_asyncioon Python 3.12+ (#1)You can also set
error_on_mispatched=Trueto turn the warning into aRuntimeError, regardless of the Python version.
nest-asyncio2 v1.6.3
-
fix: not
run_close_loopby default on Python 3.12+ (Chaoses-Ib/ComfyScript#117, pyvista/pyvista#7938)See the following for details.
-
Add some pyvista tests
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
- 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
nest-asyncio2 is a fork of the unmaintained nest_asyncio, with the following changes:
- Python 3.12
loop_factoryparameter support - Python 3.14 support (
asyncio.current_task()and others are broken innest_asyncio)
All interfaces are kept as they are. To migrate, you just need to change the package and module name to nest_asyncio2.