Recent Releases of trio
trio - v0.30.0
Full Changelog: https://github.com/python-trio/trio/compare/v0.29.0...v0.30.0
Features
- Add
@trio.as_safe_channel, a wrapper that can be used to make async generators safe. This will be the suggested fix for the flake8-async lint ruleASYNC900. (https://github.com/python-trio/trio/issues/3197)
Bugfixes
- Allow
trioto be atypes.ModuleTypeand still have deprecated attributes. (https://github.com/python-trio/trio/issues/2135) - Fixed socket module for some older systems which lack
socket.AI_NUMERICSERV. Now trio works on legacy (pre-Lion) macOS. (https://github.com/python-trio/trio/issues/3133) - Update type hints for
trio.run_processandtrio.lowlevel.open_process. (https://github.com/python-trio/trio/issues/3183) - Don't mutate the global runner when MockClock is created. (https://github.com/python-trio/trio/issues/3205)
- Fix incorrect return type hint for
Nursery.start(). (https://github.com/python-trio/trio/issues/3224)
Improved documentation
- Update wording in documentation to more accurately reflect Trio's maturity. (https://github.com/python-trio/trio/issues/3216)
- Python
Published by A5rocks 10 months ago
trio - v0.29.0
Full Changelog: https://github.com/python-trio/trio/compare/v0.28.0...v0.29.0
Features
- Add
trio.lowlevel.in_trio_runandtrio.lowlevel.in_trio_taskand document the semantics (and differences) thereof. (https://github.com/python-trio/trio/issues/2757) - If
trio.testing.RaisesGroupdoes not get the expected exceptions it now raises anAssertionErrorwith a helpful message, instead of letting the raised exception/group fall through. The raised exception is available in the__context__of theAssertionErrorand can be seen in the traceback. (https://github.com/python-trio/trio/issues/3145)
Bugfixes
- Clear Trio's cache of worker threads upon
os.fork. (https://github.com/python-trio/trio/issues/2764)
Miscellaneous internal changes
- Stop using ctypes to mutate tracebacks for
strict_exception_groups=False's exception collapsing. (https://github.com/python-trio/trio/issues/405) - Fixed spelling error in Windows error code enum for
ERROR_INVALID_PARAMETER. (https://github.com/python-trio/trio/issues/3166) - Publicly re-export
__version__for type checking purposes. (https://github.com/python-trio/trio/issues/3186) - The typing of
trio.abc.HostnameResolver.getaddrinfohas been corrected to match that of the stdlibsocket.getaddrinfo, which was updated in mypy 1.15 (via a typeshed update) to include the possibility oftuple[int, bytes]for thesockaddrfield of the result. This happens in situations where Python was compiled with--disable-ipv6.
Additionally, the static typing of trio.to_thread.run_sync, trio.from_thread.run and trio.from_thread.run_sync has been improved and should reflect the underlying function being run. (https://github.com/python-trio/trio/issues/3201)
- Python
Published by A5rocks about 1 year ago
trio - v0.28.0
Full Changelog: https://github.com/python-trio/trio/compare/v0.27.0...v0.28.0
Bugfixes
- :func:
inspect.iscoroutinefunctionand the like now give correct answers when called on KI-protected functions. (https://github.com/python-trio/trio/issues/2670) Rework KeyboardInterrupt protection to track code objects, rather than frames, as protected or not. The new implementation no longer needs to access
frame.f_localsdictionaries, so it won't artificially extend the lifetime of local variables. Since KeyboardInterrupt protection is now imposed statically (when a protected function is defined) rather than each time the function runs, its previously-noticeable performance overhead should now be near zero. The lack of a call-time wrapper has some other benefits as well:- :func:
inspect.iscoroutinefunctionand the like now give correct answers when called on KI-protected functions. - Calling a synchronous KI-protected function no longer pushes an additional stack frame, so tracebacks are clearer.
- A synchronous KI-protected function invoked from C code (such as a weakref finalizer) is now guaranteed to start executing; previously there would be a brief window in which KeyboardInterrupt could be raised before the protection was established.
- :func:
One minor drawback of the new approach is that multiple instances of the same
closure share a single KeyboardInterrupt protection state (because they share a
single code object). That means that if you apply
trio.lowlevel.enable_ki_protection to some of them
and not others, you won't get the protection semantics you asked for. See the
documentation of trio.lowlevel.enable_ki_protection
for more details and a workaround. (https://github.com/python-trio/trio/issues/3108)
- Rework foreign async generator finalization to track async generator
ids rather than mutating ag_frame.f_locals. This fixes an issue
with the previous implementation: locals' lifetimes will no longer be
extended by materialization in the ag_frame.f_locals dictionary that
the previous finalization dispatcher logic needed to access to do its work. (https://github.com/python-trio/trio/issues/3112)
- Ensure that Pyright recognizes our underscore prefixed attributes for attrs classes. (https://github.com/python-trio/trio/issues/3114)
- Fix trio.testing.RaisesGroup's typing. (https://github.com/python-trio/trio/issues/3141)
Improved documentation
- Improve error message when run after gevent's monkey patching. (https://github.com/python-trio/trio/issues/3087)
- Document that
trio.sleep_foreveris guaranteed to raise an exception now. (https://github.com/python-trio/trio/issues/3113)
Removals without deprecations
- Remove workaround for OpenSSL 1.1.1 DTLS ClientHello bug. (https://github.com/python-trio/trio/issues/3097)
- Drop support for Python 3.8. (https://github.com/python-trio/trio/issues/3104) (https://github.com/python-trio/trio/issues/3106)
Miscellaneous internal changes
- Switch to using PEP570 for positional-only arguments for
trio.socket.SocketType's methods. (https://github.com/python-trio/trio/issues/3094) - Improve type annotations in several places by removing
Anyusage. (https://github.com/python-trio/trio/issues/3121) - Get and enforce 100% coverage (https://github.com/python-trio/trio/issues/3159)
- Python
Published by A5rocks about 1 year ago
trio - v0.27.0
Full Changelog: https://github.com/python-trio/trio/compare/v0.26.2...v0.27.0
Breaking changes
trio.move_on_afterandtrio.fail_afterpreviously set the deadline relative to initialization time, instead of more intuitively upon entering the context manager. This might change timeouts if a program relied on this behavior. If you want to restore previous behavior you should instead usetrio.move_on_at(trio.current_time() + ...). flake8-async has a new rule to catch this, in case you're supporting older trio versions. SeeASYNC122. (https://github.com/python-trio/trio/issues/2512)
Features
CancelScope.relative_deadlineandCancelScope.is_relativeadded, as well as arelative_deadlineparameter to__init__. This allows initializing scopes ahead of time, but where the specified relative deadline doesn't count down until the scope is entered. (https://github.com/python-trio/trio/issues/2512)trio.Lockandtrio.StrictFIFOLockwill now raisetrio.BrokenResourceErrorwhentrio.Lock.acquirewould previously stall due to the owner of the lock exiting without releasing the lock. (https://github.com/python-trio/trio/issues/3035)trio.move_on_at,trio.move_on_after,trio.fail_atandtrio.fail_afternow accept shield as a keyword argument. If specified, it provides an initial value for the~trio.CancelScope.shieldattribute of thetrio.CancelScopeobject created by the context manager. (https://github.com/python-trio/trio/issues/3052)- Added
trio.lowlevel.add_parking_lot_breakerandtrio.lowlevel.remove_parking_lot_breakerto allow creating custom lock/semaphore implementations that will break their underlying parking lot if a task exits unexpectedly.trio.lowlevel.ParkingLot.break_lotis also added, to allow breaking a parking lot intentionally. (https://github.com/python-trio/trio/issues/3081)
Bugfixes
- Allow sockets to bind any
os.PathLikeobject. (https://github.com/python-trio/trio/issues/3041) - Update
trio.lowlevel.open_process's documentation to allow bytes. (https://github.com/python-trio/trio/issues/3076) - Update
trio.sleep_foreverto beNoReturn. (https://github.com/python-trio/trio/issues/3095)
Improved documentation
- Add docstrings for memory channels'
statistics()andaclosemethods. (https://github.com/python-trio/trio/issues/3101)
- Python
Published by A5rocks over 1 year ago
trio - v0.26.1
Full Changelog: https://github.com/python-trio/trio/compare/v0.26.0...v0.26.1
Bugfixes
- Switched
attrsusage off ofhash, which is now deprecated. (https://github.com/python-trio/trio/issues/3053)
Miscellaneous internal changes
- Use PyPI's Trusted Publishers to make releases. (https://github.com/python-trio/trio/issues/2980)
- Python
Published by A5rocks over 1 year ago
trio - v0.26.0
Full Changelog: https://github.com/python-trio/trio/compare/v0.25.1...v0.26.0
Features
- Added an interactive interpreter
python -m trio.
This makes it easier to try things and experiment with trio in the a Python repl.
Use the await keyword without needing to call trio.run()
```sh $ python -m trio Trio 0.26.0, Python 3.10.6 Use "await" directly instead of "trio.run()". Type "help", "copyright", "credits" or "license" for more information.
import trio await trio.sleep(1); print("hi") # prints after one second hi ```
See interactive debugging for further detail. (https://github.com/python-trio/trio/issues/2972)
- trio.testing.RaisesGroup can now catch an unwrapped exception with unwrapped=True. This means that the behaviour of except* can be fully replicated in combination with flatten_subgroups=True (formerly strict=False). (https://github.com/python-trio/trio/issues/2989)
Bugfixes
- Fixed a bug where
trio.testing.RaisesGroup(..., strict=False)would check the number of exceptions in the raisedExceptionGroupbefore flattening subgroups, leading to incorrectly failed matches. It now properly supports end ($) regex markers in thematchmessage, by no longer including " (x sub-exceptions)" in the string it matches against. (https://github.com/python-trio/trio/issues/2989)
Deprecations and removals
- Deprecated
strictparameter fromtrio.testing.RaisesGroup, previous functionality ofstrict=Falseis now inflatten_subgroups=True. (https://github.com/python-trio/trio/issues/2989)
- Python
Published by A5rocks over 1 year ago
trio - v0.25.1
Full Changelog: https://github.com/python-trio/trio/compare/v0.25.0...v0.25.1
Bugfixes
- Fix crash when importing trio in embedded Python on Windows, and other installs that remove docstrings. (https://github.com/python-trio/trio/issues/2987)
- Python
Published by A5rocks almost 2 years ago
trio - v0.25.0
Full Changelog: https://github.com/python-trio/trio/compare/v0.24.0...v0.25.0
Breaking changes
- The
strict_exception_groupsparameter now defaults toTrueintrio.runandtrio.lowlevel.start_guest_run.trio.open_nurserystill defaults to the same value as was specified intrio.run/trio.lowlevel.start_guest_run, but if you didn't specify it there then all subsequent calls totrio.open_nurserywill change. This is unfortunately very tricky to change with a deprecation period, as raising aDeprecationWarningwheneverstrict_exception_groupsis not specified would raise a lot of unnecessary warnings.
Notable side effects of changing code to run with strict_exception_groups==True
- If an iterator raises
StopAsyncIterationorStopIterationinside a nursery, then python will not recognize wrapped instances of those for stopping iteration. trio.run_processis now documented that it can raise anExceptionGroup. It previously could do this in very rare circumstances, but withstrict_exception_groupsset toTrueit will now do so whenever exceptions occur indeliver_cancelor with problems communicating with the subprocess.- Errors in opening the process is now done outside the internal nursery, so if code previously ran with
strict_exception_groups=Truethere are cases now where anExceptionGroupis no longer added.
- Errors in opening the process is now done outside the internal nursery, so if code previously ran with
trio.TrioInternalError.__cause__might be wrapped in one or moreExceptionGroups <ExceptionGroup>(https://github.com/python-trio/trio/issues/2786)
Features
- Add
trio.testing.wait_all_threads_completed, which blocks until no threads are running tasks. This is intended to be used in the same way astrio.testing.wait_all_tasks_blocked. (https://github.com/python-trio/trio/issues/2937) Pathis now a subclass ofpathlib.PurePath, allowing it to interoperate with other standardpathlibtypes.
Instantiating Path now returns a concrete platform-specific subclass, one of PosixPath or
WindowsPath, matching the behavior of pathlib.Path. (https://github.com/python-trio/trio/issues/2959)
Bugfixes
- The pthread functions are now correctly found on systems using vanilla versions of musl libc. (https://github.com/python-trio/trio/issues/2939)
Miscellaneous internal changes
- use the regular readme for the PyPI long_description (https://github.com/python-trio/trio/issues/2866)
- Python
Published by A5rocks almost 2 years ago
trio - v0.24.0
Full Changelog: https://github.com/python-trio/trio/compare/v0.23.2...v0.24.0
Features
- New helper classes:
testing.RaisesGroupandtesting.Matcher.
In preparation for changing the default of strict_exception_groups to True, we're introducing a set of helper classes that can be used in place of pytest.raises in tests, to check for an expected ExceptionGroup.
These are provisional, and only planned to be supplied until there's a good solution in pytest. See https://github.com/pytest-dev/pytest/issues/11538 (https://github.com/python-trio/trio/issues/2785)
Deprecations and removals
MultiErrorhas been fully removed, and all relevant trio functions now raise ExceptionGroups instead. This should not affect end users that have transitioned to usingexcept*or catching ExceptionGroup/BaseExceptionGroup. (https://github.com/python-trio/trio/issues/2891)
- Python
Published by A5rocks about 2 years ago
trio - v0.23.2
Full Changelog: https://github.com/python-trio/trio/compare/v0.23.1...v0.23.2
Features
- TypeVarTuple is now used to fully type
nursery.start_soon(),trio.run(),trio.to_thread.run_sync(), and other similar functions accepting(func, *args). This means type checkers will be able to verify types are used correctly.nursery.start()is not fully typed yet however. (https://github.com/python-trio/trio/issues/2881)
Bugfixes
- Make pyright recognize
open_memory_channelas generic. (https://github.com/python-trio/trio/issues/2873)
Miscellaneous internal changes
- Moved the metadata into PEP621-compliant
pyproject.toml. (https://github.com/python-trio/trio/issues/2860) - do not depend on exceptiongroup pre-release (https://github.com/python-trio/trio/issues/2861)
- Move .coveragerc into pyproject.toml (https://github.com/python-trio/trio/issues/2867)
- Python
Published by A5rocks about 2 years ago
trio - v0.23.1
Full Changelog: https://github.com/python-trio/trio/compare/v0.23.0...v0.23.1
Bugfixes
- Don't crash on import in Anaconda interpreters. (https://github.com/python-trio/trio/issues/2855)
- Python
Published by A5rocks over 2 years ago
trio - v0.23.0
Full Changelog: https://github.com/python-trio/trio/compare/v0.22.2...v0.23.0
Headline features
- Add type hints. (https://github.com/python-trio/trio/issues/543)
Features
- When exiting a nursery block, the parent task always waits for child tasks to exit. This wait cannot be cancelled. However, previously, if you tried to cancel it, it would inject a
Cancelledexception, even though it wasn't cancelled. Most users probably never noticed either way, but injecting aCancelledhere is not really useful, and in some rare cases caused confusion or problems, so Trio no longer does that. (https://github.com/python-trio/trio/issues/1457) - If called from a thread spawned by
trio.to_thread.run_sync,trio.from_thread.runandtrio.from_thread.run_syncnow reuse the task and cancellation status of the host task; this means that context variables and cancel scopes naturally propagate 'through' threads spawned by Trio. You can also usetrio.from_thread.check_cancelledto efficiently check for cancellation without reentering the Trio thread. (https://github.com/python-trio/trio/issues/2392) trio.lowlevel.start_guest_runnow does a bit more setup of the guest run before it returns to its caller, so that the caller can immediately make calls totrio.current_time,trio.lowlevel.spawn_system_task,trio.lowlevel.current_trio_token, etc. (https://github.com/python-trio/trio/issues/2696)
Bugfixes
- When a starting function raises before calling
trio.TaskStatus.started,trio.Nursery.startwill no longer wrap the exception in an undocumentedExceptionGroup. Previously,trio.Nursery.startwould incorrectly raise anExceptionGroupcontaining it when usingtrio.run(..., strict_exception_groups=True). (https://github.com/python-trio/trio/issues/2611)
Deprecations and removals
- To better reflect the underlying thread handling semantics, the keyword argument for
trio.to_thread.run_syncthat was previously calledcancellableis now namedabandon_on_cancel. It still does the same thing -- allow the thread to be abandoned if the call totrio.to_thread.run_syncis cancelled -- but since we now have other ways to propagate a cancellation without abandoning the thread, "cancellable" has become somewhat of a misnomer. The oldcancellablename is now deprecated. (https://github.com/python-trio/trio/issues/2841) - Deprecated support for
math.inffor thebacklogargument inopen_tcp_listeners, making its docstring correct in the fact that onlyTypeErroris raised if invalid arguments are passed. (https://github.com/python-trio/trio/issues/2842)
Removals without deprecations
- Drop support for Python3.7 and PyPy3.7/3.8. (https://github.com/python-trio/trio/issues/2668)
- Removed special
MultiErrortraceback handling for IPython. As of version 8.15ExceptionGroupis handled natively. (https://github.com/python-trio/trio/issues/2702)
Miscellaneous internal changes
- Trio now indicates its presence to
sniffiousing thesniffio.thread_localinterface that is preferred since sniffio v1.3.0. This should be less likely than the previous approach to causesniffio.current_async_libraryto return incorrect results due to unintended inheritance of contextvars. (https://github.com/python-trio/trio/issues/2700) - On windows, if SIOBASEHANDLE failed and SIOBSPHANDLE_POLL didn't return a different socket, runtime error will now raise from the OSError that indicated the issue so that in the event it does happen it might help with debugging. (https://github.com/python-trio/trio/issues/2807)
- Python
Published by A5rocks over 2 years ago