trio-asyncio 0.13.0 (2023-12-01)¶
async with trio_asyncio.open_loop():block now cancels any asyncio tasks that are still running in the background, like
asyncio.run()does, so that they have a chance to clean up resources by running async context managers and
finallyblocks. Previously such tasks would simply be abandoned to the garbage collector, resulting in potential deadlocks and stderr spew. Note that, like
asyncio.run(), we do still abandon any tasks that are started during this finalization phase and outlive the existing tasks. (#91)
A deadlock will no longer occur if
trio_asyncio.open_loop()is cancelled before its first checkpoint. We also now cancel and wait on all asyncio tasks even if
open_loop()terminates due to an exception that was raised within the
async withblock. (#115)
loop.add_writer()with a socket object (rather than a file descriptor) will no longer potentially produce spurious uncaught exceptions if the socket is closed in the reader/writer callback. (#121)
trio-asyncionow requires Trio 0.22 and does not produce deprecation warnings. Python 3.12 is now supported. Python 3.6 and 3.7 are no longer supported. (#121)
trio-asyncio now indicates its presence to
sniffio.thread_localinterface that is preferred since sniffio v1.3.0. This should be less likely than the previous approach to cause
sniffio.current_async_library()to return incorrect results due to unintended inheritance of contextvars. (#123)
trio-asyncio 0.12.0 (2021-01-07)¶
trio-asyncio now cancels any Trio tasks that were started inside a trio-asyncio loop (using e.g.
trio_as_aio()) before it allows the trio-asyncio loop to close. This should resolve some cases of deadlocks and “RuntimeError: Event loop is closed” when an
async with open_loop():block is cancelled. (#89)
On Python versions with native contextvars support (3.7+), a Trio task started from asyncio context (using
trio_as_future(), etc) will now properly inherit the contextvars of its caller. Also, if the entire trio-asyncio loop is cancelled, such tasks will no longer let
trio.Cancelledexceptions leak into their asyncio caller. (#76)
Previously, cancelling the context surrounding an
open_loop()block might cause a deadlock in some cases. The ordering of operations during loop teardown has been improved, so this shouldn’t happen anymore. (#81)
Deprecations and Removals¶
A number of functions deprecated since 0.10.0 are now removed:
trio-asyncio 0.11.0 (2020-03-09)¶
Substantially reorganize monkeypatching for asyncio event loop and event loop policy accessors, fixing support for Python 3.8. Also, stop using features deprecated in Trio 0.12. (#66)
loop.stopmanually no longer causes a deadlock when exiting the context of
Replace uses of deprecated
Deprecations and Removals¶
The non-underscore-prefixed names of trio-asyncio submodules (
trio_asyncio.adapter, etc) have been deprecated; public names should be imported from
trio_asyncio.TrioPolicyhave been deprecated with no replacement.
current_policyis no longer used at all, and the other two are singletons that can’t be customized so there’s no reason to make them publicly visible.
A number of functions which were already documented as deprecated now raise the new
TrioAsyncioDeprecationWarningwhere previously they provided either no runtime warning or a generic
trio-asyncio 0.10.0 (2018-12-09)¶
trio.Queuewith new channels, requiring Trio 0.9 or later. (#49)
trio-asyncio 0.9.1 (2018-09-06)¶
Defer creating an asyncio coroutine until asyncio mode is actually entered. (#40)
trio-asyncio 0.9.0 (2018-08-31)¶
Deprecations and Removals¶
run_asyncio()is deprecated: replace with a
trio2aio()is deprecated: replace with
TrioEventLoop.run_future()are deprecated: replace with
TrioEventLoop.run_coroutine()are deprecated: replace with
TrioEventLoop.wrap_generator()is deprecated: replace with a
trio-asyncio 0.8.2 (2018-08-25)¶
sniffio.current_async_library()in a trio-asyncio program now returns the correct value for the current mode (
trio-asyncio 0.8.1 (2018-08-25)¶
import asyncio import trio from trio_asyncio import run, allow_asyncio async def main(): print("Sleeping 1") await asyncio.sleep(1) print("Sleeping 2") await trio.sleep(1) run(allow_asyncio, main)
TrioEventLoop.run_asyncio()now supports wrapping async iterators and async context managers, in addition to its existing support for async functions.
trio-asyncio 0.8.0 (2018-08-03)¶
trio-asyncio 0.7.5 (2018-07-23)¶
Use a contextvar to represent the current trio-asyncio loop, rather than the deprecated
outcomelibrary rather than the deprecated
Better handle errors in wrapped async generators.
trio-asyncio 0.7.0 (2018-03-27)¶
@aio2triodecorators now can be used to decorate both async generator functions and async functions that take keyword arguments.
open_loop()now takes an optional
queue_len=parameter to specify the length of the internal callback queue (for performance tuning).
run_generator()which adapt an asyncio-flavored async generator to be used from Trio code.
trio-asyncio 0.5.0 (2018-02-20)¶
Support contextvars on Python 3.7 and later.
Support waiting for child processes even though Trio doesn’t (yet).
trio-asyncio 0.4.2 (2018-02-12)¶
Fix a deadlock in
SyncTrioEventLoop. Encourage people to use the async
trio-asyncio 0.4.1 (2018-02-08)¶
TrioEventLoop.run_task()as an entry point for running Trio code in a context that allows asyncio calls, for use when neither a Trio nor an asyncio event loop is running.
trio-asyncio 0.4.0 (2018-02-07)¶
Add support for async loops (
open_loop()) and encourage their use. Numerous functions renamed.
trio-asyncio 0.3.0 (2017-10-17)¶