Debian Codegraph @

docs/source/history.rst

raw
1 Release history
2 ===============
3
4 .. currentmodule:: trio
5
6 .. towncrier release notes start
7
8 trio 0.34.0 (2026-08-10)
9 ------------------------
10
11 Features
12 ~~~~~~~~
13
14 - `MemoryChannelStatistics` now has a ``peak_buffer_used`` field, which reports
15 the largest number of items that have ever been in the channel's buffer at
16 once. This makes it easier to pick a sensible ``max_buffer_size`` based on
17 data from a real run, instead of guessing. (`#1723 <https://github.com/python-trio/trio/issues/1723>`__)
18 - Support Python 3.15, as of beta 4. Things may still change and so this
19 support may break in the future. (`#3456 <https://github.com/python-trio/trio/issues/3456>`__)
20
21
22 Bugfixes
23 ~~~~~~~~
24
25 - ``Nursery.start()`` now preserves the ``__cause__`` and ``__context__`` of
26 exceptions raised before ``task_status.started()`` is called. (`#3261 <https://github.com/python-trio/trio/issues/3261>`__)
27 - Fixed incorrect error message in ``run_process``: the ``stdout`` pipe check now correctly says "stdout" instead of "stdin". (`#3409 <https://github.com/python-trio/trio/issues/3409>`__)
28 - Fixed ``trio.Path.as_uri()`` on Python 3.14+ to avoid the deprecated ``pathlib.PurePath.as_uri()`` path. (`#3460 <https://github.com/python-trio/trio/issues/3460>`__)
29 - Fixed ``trio.to_thread.run_sync``` workers leaking spawner's ``Context`` on ``py314t+`` free-threaded builds. (`#3472 <https://github.com/python-trio/trio/issues/3472>`__)
30
31
32 Deprecations and removals
33 ~~~~~~~~~~~~~~~~~~~~~~~~~
34
35 - Trying to use absolute deadlines on a `trio.CancelScope` constructed
36 with a relative deadline now raises, after being deprecated since Trio
37 0.27.0.
38
39 To switch a cancel scope from being relative to absolute, replace the
40 `trio.CancelScope` object instead of trying to mutate it. (`#3403 <https://github.com/python-trio/trio/issues/3403>`__)
41
42
43 trio 0.33.0 (2026-02-14)
44 ------------------------
45
46 Bugfixes
47 ~~~~~~~~
48
49 - Start supporting Android's new ``"android"`` `sys.platform`. (`#3357 <https://github.com/python-trio/trio/issues/3357>`__)
50
51
52 Deprecations and removals
53 ~~~~~~~~~~~~~~~~~~~~~~~~~
54
55 - Both :class:`trio.testing.RaisesGroup` and :class:`trio.testing.Matcher` have been deprecated. Pytest alternatives ``pytest.RaisesGroup`` and ``pytest.RaisesExc`` (respectively) are considered correct replacement. (`#3326 <https://github.com/python-trio/trio/issues/3326>`__)
56
57
58 trio 0.32.0 (2025-10-31)
59 ------------------------
60
61 Features
62 ~~~~~~~~
63
64 - Allow `trio.CapacityLimiter` to have zero total_tokens. (`#3321 <https://github.com/python-trio/trio/issues/3321>`__)
65
66
67 Bugfixes
68 ~~~~~~~~
69
70 - Fixed a bug where iterating over an ``@as_safe_channel``-derived ``ReceiveChannel``
71 would raise `~trio.BrokenResourceError` if the channel was closed by another task.
72 It now shuts down cleanly. (`#3331 <https://github.com/python-trio/trio/issues/3331>`__)
73 - `trio.lowlevel.Task.iter_await_frames` now works on completed tasks, by
74 returning an empty list of frames if the underlying coroutine has been closed.
75 Previously, it raised an internal error. (`#3337 <https://github.com/python-trio/trio/issues/3337>`__)
76
77
78 Removals without deprecations
79 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80
81 - Drop support for Python 3.9. (`#3345 <https://github.com/python-trio/trio/issues/3345>`__)
82
83
84 Miscellaneous internal changes
85 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
87 - Decrease indentation for exception groups raised in `trio.as_safe_channel`. (`#3332 <https://github.com/python-trio/trio/issues/3332>`__)
88
89
90 Trio 0.31.0 (2025-09-09)
91 ------------------------
92
93 Features
94 ~~~~~~~~
95
96 - :exc:`Cancelled` strings can now display the source and reason for a cancellation. Trio-internal sources of cancellation will set this string, and :meth:`CancelScope.cancel` now has a ``reason`` string parameter that can be used to attach info to any :exc:`Cancelled` to help in debugging. (`#3232 <https://github.com/python-trio/trio/issues/3232>`__)
97
98
99 Bugfixes
100 ~~~~~~~~
101
102 - Make ctrl+c work in more situations in the Trio REPL (``python -m trio``). (`#3007 <https://github.com/python-trio/trio/issues/3007>`__)
103 - Allow pickling `trio.Cancelled`, as they can show up when you want to pickle something else. This does not rule out pickling other ``NoPublicConstructor`` objects -- create an issue if necessary. (`#3248 <https://github.com/python-trio/trio/issues/3248>`__)
104 - Decrease import time on Windows by around 10%. (`#3263 <https://github.com/python-trio/trio/issues/3263>`__)
105 - Handle unwrapping SystemExit/KeyboardInterrupt exception gracefully in utility function ``raise_single_exception_from_group`` that reraises last exception from group. (`#3275 <https://github.com/python-trio/trio/issues/3275>`__)
106 - Ensure that the DTLS server does not mutate SSL context. (`#3277 <https://github.com/python-trio/trio/issues/3277>`__)
107 - Avoid having `trio.as_safe_channel` raise if closing the generator wrapped
108 `GeneratorExit` in a `BaseExceptionGroup`. (`#3324 <https://github.com/python-trio/trio/issues/3324>`__)
109
110
111 Deprecations and removals
112 ~~~~~~~~~~~~~~~~~~~~~~~~~
113
114 - Implement ``bool(trio.Event)`` and have it raise a `DeprecationWarning` and tell users to use `trio.Event.is_set` instead. This is an alternative to ``mypy --enable-error-code=truthy-bool`` for users who don't use type checking. (`#3322 <https://github.com/python-trio/trio/issues/3322>`__)
115
116
117 Miscellaneous internal changes
118 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119
120 - When misnesting nurseries you now get a helpful :exc:`RuntimeError` instead of a catastrophic :exc:`TrioInternalError`. (`#3307 <https://github.com/python-trio/trio/issues/3307>`__)
121
122
123 Trio 0.30.0 (2025-04-20)
124 ------------------------
125
126 Features
127 ~~~~~~~~
128
129 - Add :func:`@trio.as_safe_channel <trio.as_safe_channel>`, a wrapper that can be used to make async generators safe.
130 This will be the suggested fix for the flake8-async lint rule `ASYNC900 <https://flake8-async.readthedocs.io/en/latest/rules.html#async900>`_. (`#3197 <https://github.com/python-trio/trio/issues/3197>`__)
131
132
133 Bugfixes
134 ~~~~~~~~
135
136 - Allow `trio` to be a `types.ModuleType` and still have deprecated attributes. (`#2135 <https://github.com/python-trio/trio/issues/2135>`__)
137 - Fixed socket module for some older systems which lack ``socket.AI_NUMERICSERV``.
138 Now trio works on legacy (pre-Lion) macOS. (`#3133 <https://github.com/python-trio/trio/issues/3133>`__)
139 - Update type hints for `trio.run_process` and `trio.lowlevel.open_process`. (`#3183 <https://github.com/python-trio/trio/issues/3183>`__)
140 - Don't mutate the global runner when MockClock is created. (`#3205 <https://github.com/python-trio/trio/issues/3205>`__)
141 - Fix incorrect return type hint for :meth:`Nursery.start() <trio.Nursery.start>`. (`#3224 <https://github.com/python-trio/trio/issues/3224>`__)
142
143
144 Improved documentation
145 ~~~~~~~~~~~~~~~~~~~~~~
146
147 - Update wording in documentation to more accurately reflect Trio's maturity. (`#3216 <https://github.com/python-trio/trio/issues/3216>`__)
148
149
150 Trio 0.29.0 (2025-02-14)
151 ------------------------
152
153 Features
154 ~~~~~~~~
155
156 - Add :func:`trio.lowlevel.in_trio_run` and :func:`trio.lowlevel.in_trio_task` and document the semantics (and differences) thereof. See :ref:`the documentation <trio_contexts>`. (`#2757 <https://github.com/python-trio/trio/issues/2757>`__)
157 - If `trio.testing.RaisesGroup` does not get the expected exceptions it now raises an `AssertionError` with a helpful message, instead of letting the raised exception/group fall through. The raised exception is available in the ``__context__`` of the `AssertionError` and can be seen in the traceback. (`#3145 <https://github.com/python-trio/trio/issues/3145>`__)
158
159
160 Bugfixes
161 ~~~~~~~~
162
163 - Clear Trio's cache of worker threads upon `os.fork`. (`#2764 <https://github.com/python-trio/trio/issues/2764>`__)
164
165
166 Miscellaneous internal changes
167 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168
169 - Stop using ctypes to mutate tracebacks for ``strict_exception_groups=False``'s exception collapsing. (`#405 <https://github.com/python-trio/trio/issues/405>`__)
170 - Fixed spelling error in Windows error code enum for ``ERROR_INVALID_PARAMETER``. (`#3166 <https://github.com/python-trio/trio/issues/3166>`__)
171 - Publicly re-export ``__version__`` for type checking purposes. (`#3186 <https://github.com/python-trio/trio/issues/3186>`__)
172 - The typing of :func:`trio.abc.HostnameResolver.getaddrinfo` has been corrected to
173 match that of the stdlib `socket.getaddrinfo`, which was updated in mypy 1.15 (via
174 a typeshed update) to include the possibility of ``tuple[int, bytes]`` for the
175 ``sockaddr`` field of the result. This happens in situations where Python was compiled
176 with ``--disable-ipv6``.
177
178 Additionally, the static typing of :func:`trio.to_thread.run_sync`,
179 :func:`trio.from_thread.run` and :func:`trio.from_thread.run_sync` has been
180 improved and should reflect the underlying function being run. (`#3201 <https://github.com/python-trio/trio/issues/3201>`__)
181
182
183 Trio 0.28.0 (2024-12-25)
184 ------------------------
185
186 Bugfixes
187 ~~~~~~~~
188
189 - :func:`inspect.iscoroutinefunction` and the like now give correct answers when
190 called on KI-protected functions. (`#2670 <https://github.com/python-trio/trio/issues/2670>`__)
191 - Rework KeyboardInterrupt protection to track code objects, rather than frames,
192 as protected or not. The new implementation no longer needs to access
193 ``frame.f_locals`` dictionaries, so it won't artificially extend the lifetime of
194 local variables. Since KeyboardInterrupt protection is now imposed statically
195 (when a protected function is defined) rather than each time the function runs,
196 its previously-noticeable performance overhead should now be near zero.
197 The lack of a call-time wrapper has some other benefits as well:
198
199 * :func:`inspect.iscoroutinefunction` and the like now give correct answers when
200 called on KI-protected functions.
201
202 * Calling a synchronous KI-protected function no longer pushes an additional stack
203 frame, so tracebacks are clearer.
204
205 * A synchronous KI-protected function invoked from C code (such as a weakref
206 finalizer) is now guaranteed to start executing; previously there would be a brief
207 window in which KeyboardInterrupt could be raised before the protection was
208 established.
209
210 One minor drawback of the new approach is that multiple instances of the same
211 closure share a single KeyboardInterrupt protection state (because they share a
212 single code object). That means that if you apply
213 `@enable_ki_protection <trio.lowlevel.enable_ki_protection>` to some of them
214 and not others, you won't get the protection semantics you asked for. See the
215 documentation of `@enable_ki_protection <trio.lowlevel.enable_ki_protection>`
216 for more details and a workaround. (`#3108 <https://github.com/python-trio/trio/issues/3108>`__)
217 - Rework foreign async generator finalization to track async generator
218 ids rather than mutating ``ag_frame.f_locals``. This fixes an issue
219 with the previous implementation: locals' lifetimes will no longer be
220 extended by materialization in the ``ag_frame.f_locals`` dictionary that
221 the previous finalization dispatcher logic needed to access to do its work. (`#3112 <https://github.com/python-trio/trio/issues/3112>`__)
222 - Ensure that Pyright recognizes our underscore prefixed attributes for attrs classes. (`#3114 <https://github.com/python-trio/trio/issues/3114>`__)
223 - Fix `trio.testing.RaisesGroup`'s typing. (`#3141 <https://github.com/python-trio/trio/issues/3141>`__)
224
225
226 Improved documentation
227 ~~~~~~~~~~~~~~~~~~~~~~
228
229 - Improve error message when run after gevent's monkey patching. (`#3087 <https://github.com/python-trio/trio/issues/3087>`__)
230 - Document that :func:`trio.sleep_forever` is guaranteed to raise an exception now. (`#3113 <https://github.com/python-trio/trio/issues/3113>`__)
231
232
233 Removals without deprecations
234 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
236 - Remove workaround for OpenSSL 1.1.1 DTLS ClientHello bug. (`#3097 <https://github.com/python-trio/trio/issues/3097>`__)
237 - Drop support for Python 3.8. (`#3104 <https://github.com/python-trio/trio/issues/3104>`__) (`#3106 <https://github.com/python-trio/trio/issues/3106>`__)
238
239
240 Miscellaneous internal changes
241 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
242
243 - Switch to using :pep:`570` for positional-only arguments for `~trio.socket.SocketType`'s methods. (`#3094 <https://github.com/python-trio/trio/issues/3094>`__)
244 - Improve type annotations in several places by removing `Any` usage. (`#3121 <https://github.com/python-trio/trio/issues/3121>`__)
245 - Get and enforce 100% coverage (`#3159 <https://github.com/python-trio/trio/issues/3159>`__)
246
247
248 Trio 0.27.0 (2024-10-17)
249 ------------------------
250
251 Breaking changes
252 ~~~~~~~~~~~~~~~~
253
254 - :func:`trio.move_on_after` and :func:`trio.fail_after` previously 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 use ``trio.move_on_at(trio.current_time() + ...)``.
255 flake8-async has a new rule to catch this, in case you're supporting older trio versions. See :ref:`ASYNC122`. (`#2512 <https://github.com/python-trio/trio/issues/2512>`__)
256
257
258 Features
259 ~~~~~~~~
260
261 - :meth:`CancelScope.relative_deadline` and :meth:`CancelScope.is_relative` added, as well as a ``relative_deadline`` parameter to ``__init__``. This allows initializing scopes ahead of time, but where the specified relative deadline doesn't count down until the scope is entered. (`#2512 <https://github.com/python-trio/trio/issues/2512>`__)
262 - :class:`trio.Lock` and :class:`trio.StrictFIFOLock` will now raise :exc:`trio.BrokenResourceError` when :meth:`trio.Lock.acquire` would previously stall due to the owner of the lock exiting without releasing the lock. (`#3035 <https://github.com/python-trio/trio/issues/3035>`__)
263 - `trio.move_on_at`, `trio.move_on_after`, `trio.fail_at` and `trio.fail_after` now accept *shield* as a keyword argument. If specified, it provides an initial value for the `~trio.CancelScope.shield` attribute of the `trio.CancelScope` object created by the context manager. (`#3052 <https://github.com/python-trio/trio/issues/3052>`__)
264 - Added :func:`trio.lowlevel.add_parking_lot_breaker` and :func:`trio.lowlevel.remove_parking_lot_breaker` to allow creating custom lock/semaphore implementations that will break their underlying parking lot if a task exits unexpectedly. :meth:`trio.lowlevel.ParkingLot.break_lot` is also added, to allow breaking a parking lot intentionally. (`#3081 <https://github.com/python-trio/trio/issues/3081>`__)
265
266
267 Bugfixes
268 ~~~~~~~~
269
270 - Allow sockets to bind any ``os.PathLike`` object. (`#3041 <https://github.com/python-trio/trio/issues/3041>`__)
271 - Update ``trio.lowlevel.open_process``'s documentation to allow bytes. (`#3076 <https://github.com/python-trio/trio/issues/3076>`__)
272 - Update :func:`trio.sleep_forever` to be `NoReturn`. (`#3095 <https://github.com/python-trio/trio/issues/3095>`__)
273
274
275 Improved documentation
276 ~~~~~~~~~~~~~~~~~~~~~~
277
278 - Add docstrings for memory channels' ``statistics()`` and ``aclose`` methods. (`#3101 <https://github.com/python-trio/trio/issues/3101>`__)
279
280
281 Trio 0.26.2 (2024-08-08)
282 ------------------------
283
284 Bugfixes
285 ~~~~~~~~
286
287 - Remove remaining ``hash`` usage and fix test configuration issue that prevented it from being caught. (`#3053 <https://github.com/python-trio/trio/issues/3053>`__)
288
289
290 Trio 0.26.1 (2024-08-05)
291 ------------------------
292
293 Bugfixes
294 ~~~~~~~~
295
296 - Switched ``attrs`` usage off of ``hash``, which is now deprecated. (`#3053 <https://github.com/python-trio/trio/issues/3053>`__)
297
298
299 Miscellaneous internal changes
300 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
301
302 - Use PyPI's Trusted Publishers to make releases. (`#2980 <https://github.com/python-trio/trio/issues/2980>`__)
303
304
305 Trio 0.26.0 (2024-07-05)
306 ------------------------
307
308 Features
309 ~~~~~~~~
310
311 - Added an interactive interpreter ``python -m trio``.
312
313 This makes it easier to try things and experiment with trio in the a Python repl.
314 Use the ``await`` keyword without needing to call ``trio.run()``
315
316 .. code-block:: console
317
318 $ python -m trio
319 Trio 0.21.0+dev, Python 3.10.6
320 Use "await" directly instead of "trio.run()".
321 Type "help", "copyright", "credits" or "license" for more information.
322 >>> import trio
323 >>> await trio.sleep(1); print("hi") # prints after one second
324 hi
325
326 See :ref:`interactive debugging` for further detail. (`#2972 <https://github.com/python-trio/trio/issues/2972>`__)
327 - :class:`trio.testing.RaisesGroup` can now catch an unwrapped exception with ``unwrapped=True``. This means that the behaviour of :ref:`except* <except_star>` can be fully replicated in combination with ``flatten_subgroups=True`` (formerly ``strict=False``). (`#2989 <https://github.com/python-trio/trio/issues/2989>`__)
328
329
330 Bugfixes
331 ~~~~~~~~
332
333 - Fixed a bug where :class:`trio.testing.RaisesGroup(..., strict=False) <trio.testing.RaisesGroup>` would check the number of exceptions in the raised `ExceptionGroup` before flattening subgroups, leading to incorrectly failed matches.
334 It now properly supports end (``$``) regex markers in the ``match`` message, by no longer including " (x sub-exceptions)" in the string it matches against. (`#2989 <https://github.com/python-trio/trio/issues/2989>`__)
335
336
337 Deprecations and removals
338 ~~~~~~~~~~~~~~~~~~~~~~~~~
339
340 - Deprecated ``strict`` parameter from :class:`trio.testing.RaisesGroup`, previous functionality of ``strict=False`` is now in ``flatten_subgroups=True``. (`#2989 <https://github.com/python-trio/trio/issues/2989>`__)
341
342
343 Trio 0.25.1 (2024-05-16)
344 ------------------------
345
346 Bugfixes
347 ~~~~~~~~
348
349 - Fix crash when importing trio in embedded Python on Windows, and other installs that remove docstrings. (`#2987 <https://github.com/python-trio/trio/issues/2987>`__)
350
351
352 Trio 0.25.0 (2024-03-17)
353 ------------------------
354
355 Breaking changes
356 ~~~~~~~~~~~~~~~~
357
358 - The :ref:`strict_exception_groups <strict_exception_groups>` parameter now defaults to `True` in `trio.run` and `trio.lowlevel.start_guest_run`. `trio.open_nursery` still defaults to the same value as was specified in `trio.run`/`trio.lowlevel.start_guest_run`, but if you didn't specify it there then all subsequent calls to `trio.open_nursery` will change.
359 This is unfortunately very tricky to change with a deprecation period, as raising a `DeprecationWarning` whenever :ref:`strict_exception_groups <strict_exception_groups>` is not specified would raise a lot of unnecessary warnings.
360
361 Notable side effects of changing code to run with ``strict_exception_groups==True``
362
363 * If an iterator raises `StopAsyncIteration` or `StopIteration` inside a nursery, then python will not recognize wrapped instances of those for stopping iteration.
364 * `trio.run_process` is now documented that it can raise an `ExceptionGroup`. It previously could do this in very rare circumstances, but with :ref:`strict_exception_groups <strict_exception_groups>` set to `True` it will now do so whenever exceptions occur in ``deliver_cancel`` or with problems communicating with the subprocess.
365
366 * Errors in opening the process is now done outside the internal nursery, so if code previously ran with ``strict_exception_groups=True`` there are cases now where an `ExceptionGroup` is *no longer* added.
367 * `trio.TrioInternalError` ``.__cause__`` might be wrapped in one or more `ExceptionGroups <ExceptionGroup>` (`#2786 <https://github.com/python-trio/trio/issues/2786>`__)
368
369
370 Features
371 ~~~~~~~~
372
373 - 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 as `trio.testing.wait_all_tasks_blocked`. (`#2937 <https://github.com/python-trio/trio/issues/2937>`__)
374 - :class:`Path` is now a subclass of :class:`pathlib.PurePath`, allowing it to interoperate with other standard
375 :mod:`pathlib` types.
376
377 Instantiating :class:`Path` now returns a concrete platform-specific subclass, one of :class:`PosixPath` or
378 :class:`WindowsPath`, matching the behavior of :class:`pathlib.Path`. (`#2959 <https://github.com/python-trio/trio/issues/2959>`__)
379
380
381 Bugfixes
382 ~~~~~~~~
383
384 - The pthread functions are now correctly found on systems using vanilla versions of musl libc. (`#2939 <https://github.com/python-trio/trio/issues/2939>`__)
385
386
387 Miscellaneous internal changes
388 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
389
390 - use the regular readme for the PyPI long_description (`#2866 <https://github.com/python-trio/trio/issues/2866>`__)
391
392
393 Trio 0.24.0 (2024-01-10)
394 ------------------------
395
396 Features
397 ~~~~~~~~
398
399 - New helper classes: :class:`~.testing.RaisesGroup` and :class:`~.testing.Matcher`.
400
401 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 <https://docs.pytest.org/en/stable/reference/reference.html#pytest.raises>`_ in tests, to check for an expected `ExceptionGroup`.
402 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 (`#2785 <https://github.com/python-trio/trio/issues/2785>`__)
403
404
405 Deprecations and removals
406 ~~~~~~~~~~~~~~~~~~~~~~~~~
407
408 - ``MultiError`` has been fully removed, and all relevant trio functions now raise ExceptionGroups instead. This should not affect end users that have transitioned to using ``except*`` or catching ExceptionGroup/BaseExceptionGroup. (`#2891 <https://github.com/python-trio/trio/issues/2891>`__)
409
410
411 Trio 0.23.2 (2023-12-14)
412 ------------------------
413
414 Features
415 ~~~~~~~~
416
417 - `TypeVarTuple <https://docs.python.org/3.12/library/typing.html#typing.TypeVarTuple>`_ is now used to fully type :meth:`nursery.start_soon() <trio.Nursery.start_soon>`, :func:`trio.run`, :func:`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. :meth:`nursery.start() <trio.Nursery.start>` is not fully typed yet however. (`#2881 <https://github.com/python-trio/trio/issues/2881>`__)
418
419
420 Bugfixes
421 ~~~~~~~~
422
423 - Make pyright recognize :func:`open_memory_channel` as generic. (`#2873 <https://github.com/python-trio/trio/issues/2873>`__)
424
425
426 Miscellaneous internal changes
427 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
428
429 - Moved the metadata into :pep:`621`-compliant :file:`pyproject.toml`. (`#2860 <https://github.com/python-trio/trio/issues/2860>`__)
430 - do not depend on exceptiongroup pre-release (`#2861 <https://github.com/python-trio/trio/issues/2861>`__)
431 - Move .coveragerc into pyproject.toml (`#2867 <https://github.com/python-trio/trio/issues/2867>`__)
432
433
434 Trio 0.23.1 (2023-11-04)
435 ------------------------
436
437 Bugfixes
438 ~~~~~~~~
439
440 - Don't crash on import in Anaconda interpreters. (`#2855 <https://github.com/python-trio/trio/issues/2855>`__)
441
442
443 Trio 0.23.0 (2023-11-03)
444 ------------------------
445
446 Headline features
447 ~~~~~~~~~~~~~~~~~
448
449 - Add type hints. (`#543 <https://github.com/python-trio/trio/issues/543>`__)
450
451
452 Features
453 ~~~~~~~~
454
455 - When exiting a nursery block, the parent task always waits for child
456 tasks to exit. This wait cannot be cancelled. However, previously, if
457 you tried to cancel it, it *would* inject a `Cancelled` exception,
458 even though it wasn't cancelled. Most users probably never noticed
459 either way, but injecting a `Cancelled` here is not really useful, and
460 in some rare cases caused confusion or problems, so Trio no longer
461 does that. (`#1457 <https://github.com/python-trio/trio/issues/1457>`__)
462 - If called from a thread spawned by `trio.to_thread.run_sync`, `trio.from_thread.run` and
463 `trio.from_thread.run_sync` now reuse the task and cancellation status of the host task;
464 this means that context variables and cancel scopes naturally propagate 'through'
465 threads spawned by Trio. You can also use `trio.from_thread.check_cancelled`
466 to efficiently check for cancellation without reentering the Trio thread. (`#2392 <https://github.com/python-trio/trio/issues/2392>`__)
467 - :func:`trio.lowlevel.start_guest_run` now does a bit more setup of the guest run
468 before it returns to its caller, so that the caller can immediately make calls to
469 :func:`trio.current_time`, :func:`trio.lowlevel.spawn_system_task`,
470 :func:`trio.lowlevel.current_trio_token`, etc. (`#2696 <https://github.com/python-trio/trio/issues/2696>`__)
471
472
473 Bugfixes
474 ~~~~~~~~
475
476 - When a starting function raises before calling :func:`trio.TaskStatus.started`,
477 :func:`trio.Nursery.start` will no longer wrap the exception in an undocumented
478 :exc:`ExceptionGroup`. Previously, :func:`trio.Nursery.start` would incorrectly
479 raise an :exc:`ExceptionGroup` containing it when using ``trio.run(...,
480 strict_exception_groups=True)``. (`#2611 <https://github.com/python-trio/trio/issues/2611>`__)
481
482
483 Deprecations and removals
484 ~~~~~~~~~~~~~~~~~~~~~~~~~
485
486 - To better reflect the underlying thread handling semantics,
487 the keyword argument for `trio.to_thread.run_sync` that was
488 previously called ``cancellable`` is now named ``abandon_on_cancel``.
489 It still does the same thing -- allow the thread to be abandoned
490 if the call to `trio.to_thread.run_sync` is cancelled -- but since we now
491 have other ways to propagate a cancellation without abandoning
492 the thread, "cancellable" has become somewhat of a misnomer.
493 The old ``cancellable`` name is now deprecated. (`#2841 <https://github.com/python-trio/trio/issues/2841>`__)
494 - Deprecated support for ``math.inf`` for the ``backlog`` argument in ``open_tcp_listeners``, making its docstring correct in the fact that only ``TypeError`` is raised if invalid arguments are passed. (`#2842 <https://github.com/python-trio/trio/issues/2842>`__)
495
496
497 Removals without deprecations
498 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
499
500 - Drop support for Python3.7 and PyPy3.7/3.8. (`#2668 <https://github.com/python-trio/trio/issues/2668>`__)
501 - Removed special ``MultiError`` traceback handling for IPython. As of `version 8.15 <https://ipython.readthedocs.io/en/stable/whatsnew/version8.html#ipython-8-15>`_ `ExceptionGroup` is handled natively. (`#2702 <https://github.com/python-trio/trio/issues/2702>`__)
502
503
504 Miscellaneous internal changes
505 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
506
507 - Trio now indicates its presence to `sniffio` using the ``sniffio.thread_local``
508 interface that is preferred since sniffio v1.3.0. This should be less likely
509 than the previous approach to cause :func:`sniffio.current_async_library` to
510 return incorrect results due to unintended inheritance of contextvars. (`#2700 <https://github.com/python-trio/trio/issues/2700>`__)
511 - On windows, if SIO_BASE_HANDLE failed and SIO_BSP_HANDLE_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. (`#2807 <https://github.com/python-trio/trio/issues/2807>`__)
512
513
514 Trio 0.22.2 (2023-07-13)
515 ------------------------
516
517 Bugfixes
518 ~~~~~~~~
519
520 - Fix ``PermissionError`` when importing `trio` due to trying to access ``pthread``. (`#2688 <https://github.com/python-trio/trio/issues/2688>`__)
521
522
523 Trio 0.22.1 (2023-07-02)
524 ------------------------
525
526 Breaking changes
527 ~~~~~~~~~~~~~~~~
528
529 - Timeout functions now raise `ValueError` if passed `math.nan`. This includes `trio.sleep`, `trio.sleep_until`, `trio.move_on_at`, `trio.move_on_after`, `trio.fail_at` and `trio.fail_after`. (`#2493 <https://github.com/python-trio/trio/issues/2493>`__)
530
531
532 Features
533 ~~~~~~~~
534
535 - Added support for naming threads created with `trio.to_thread.run_sync`, requires pthreads so is only available on POSIX platforms with glibc installed. (`#1148 <https://github.com/python-trio/trio/issues/1148>`__)
536 - `trio.socket.socket` now prints the address it tried to connect to upon failure. (`#1810 <https://github.com/python-trio/trio/issues/1810>`__)
537
538
539 Bugfixes
540 ~~~~~~~~
541
542 - Fixed a crash that can occur when running Trio within an embedded Python interpreter, by handling the `TypeError` that is raised when trying to (re-)install a C signal handler. (`#2333 <https://github.com/python-trio/trio/issues/2333>`__)
543 - Fix :func:`sniffio.current_async_library` when Trio tasks are spawned from a non-Trio context (such as when using trio-asyncio). Previously, a regular Trio task would inherit the non-Trio library name, and spawning a system task would cause the non-Trio caller to start thinking it was Trio. (`#2462 <https://github.com/python-trio/trio/issues/2462>`__)
544 - Issued a new release as in the git tag for 0.22.0, ``trio.__version__`` is incorrectly set to 0.21.0+dev. (`#2485 <https://github.com/python-trio/trio/issues/2485>`__)
545
546
547 Improved documentation
548 ~~~~~~~~~~~~~~~~~~~~~~
549
550 - Documented that :obj:`Nursery.start_soon` does not guarantee task ordering. (`#970 <https://github.com/python-trio/trio/issues/970>`__)
551
552
553 Trio 0.22.0 (2022-09-28)
554 ------------------------
555
556 Headline features
557 ~~~~~~~~~~~~~~~~~
558
559 - ``MultiError`` has been deprecated in favor of the standard :exc:`BaseExceptionGroup`
560 (introduced in :pep:`654`). On Python versions below 3.11, this exception and its
561 derivative :exc:`ExceptionGroup` are provided by the backport_. Trio still raises
562 ``MultiError``, but it has been refactored into a subclass of :exc:`BaseExceptionGroup`
563 which users should catch instead of ``MultiError``. Uses of the ``MultiError.filter()``
564 class method should be replaced with :meth:`BaseExceptionGroup.split`. Uses of the
565 ``MultiError.catch()`` class method should be replaced with either ``except*`` clauses
566 (on Python 3.11+) or the ``exceptiongroup.catch()`` context manager provided by the
567 backport_.
568
569 See the :ref:`updated documentation <exceptiongroups>` for details.
570 (`#2211 <https://github.com/python-trio/trio/issues/2211>`__)
571
572 .. _backport: https://pypi.org/project/exceptiongroup/
573
574
575 Features
576 ~~~~~~~~
577
578 - Added support for `Datagram TLS
579 <https://en.wikipedia.org/wiki/Datagram_Transport_Layer_Security>`__,
580 for secure communication over UDP. Currently requires `PyOpenSSL
581 <https://pypi.org/p/pyopenssl>`__. (`#2010 <https://github.com/python-trio/trio/issues/2010>`__)
582
583
584 Trio 0.21.0 (2022-06-07)
585 ----------------------------
586
587 Features
588 ~~~~~~~~
589
590 - Trio now supports Python 3.11. (`#2270
591 <https://github.com/python-trio/trio/issues/2270>`__, `#2318
592 <https://github.com/python-trio/trio/issues/2318>`__, `#2319
593 <https://github.com/python-trio/trio/issues/2319>`__)
594
595 Deprecations and Removals
596 ~~~~~~~~~~~~~~~~~~~~~~~~~
597
598 - Remove support for Python 3.6. (`#2210 <https://github.com/python-trio/trio/issues/2210>`__)
599
600
601 Trio 0.20.0 (2022-02-21)
602 ------------------------
603
604 Features
605 ~~~~~~~~
606
607 - You can now conveniently spawn a child process in a background task
608 and interact it with on the fly using ``process = await
609 nursery.start(run_process, ...)``. See `run_process` for more details.
610 We recommend most users switch to this new API. Also note that:
611
612 - ``trio.open_process`` has been deprecated in favor of
613 `trio.lowlevel.open_process`,
614 - The ``aclose`` method on `Process` has been deprecated along with
615 ``async with process_obj``. (`#1104 <https://github.com/python-trio/trio/issues/1104>`__)
616 - Now context variables set with `contextvars` are preserved when running functions
617 in a worker thread with `trio.to_thread.run_sync`, or when running
618 functions from the worker thread in the parent Trio thread with
619 `trio.from_thread.run`, and `trio.from_thread.run_sync`.
620 This is done by automatically copying the `contextvars` context.
621 `trio.lowlevel.spawn_system_task` now also receives an optional ``context`` argument. (`#2160 <https://github.com/python-trio/trio/issues/2160>`__)
622
623
624 Bugfixes
625 ~~~~~~~~
626
627 - Trio now avoids creating cyclic garbage when a ``MultiError`` is generated and
628 filtered, including invisibly within the cancellation system. This means errors raised
629 through nurseries and cancel scopes should result in less GC latency. (`#2063 <https://github.com/python-trio/trio/issues/2063>`__)
630 - Trio now deterministically cleans up file descriptors that were opened before
631 subprocess creation fails. Previously, they would remain open until the next run of
632 the garbage collector. (`#2193 <https://github.com/python-trio/trio/issues/2193>`__)
633 - Add compatibility with OpenSSL 3.0 on newer Python and PyPy versions by working
634 around ``SSLEOFError`` not being raised properly. (`#2203 <https://github.com/python-trio/trio/issues/2203>`__)
635 - Fix a bug that could cause `Process.wait` to hang on Linux systems using pidfds, if
636 another task were to access `Process.returncode` after the process exited but before
637 ``wait`` woke up (`#2209 <https://github.com/python-trio/trio/issues/2209>`__)
638
639
640 Trio 0.19.0 (2021-06-15)
641 ------------------------
642
643 Features
644 ~~~~~~~~
645
646 - Trio now supports Python 3.10. (`#1921 <https://github.com/python-trio/trio/issues/1921>`__)
647 - Use slots for :class:`~.lowlevel.Task` which should make them slightly smaller and faster. (`#1927 <https://github.com/python-trio/trio/issues/1927>`__)
648 - Make :class:`~.Event` more lightweight by using less objects (about 2 rather
649 than 5, including a nested ParkingLot and attribute dicts) and simpler
650 structures (set rather than OrderedDict). This may benefit applications that
651 create a large number of event instances, such as with the "replace event
652 object on every set()" idiom. (`#1948 <https://github.com/python-trio/trio/issues/1948>`__)
653
654
655 Bugfixes
656 ~~~~~~~~
657
658 - The event loop now holds on to references of coroutine frames for only
659 the minimum necessary period of time. (`#1864 <https://github.com/python-trio/trio/issues/1864>`__)
660 - The :class:`~.lowlevel.TrioToken` class can now be used as a target of a weak reference. (`#1924 <https://github.com/python-trio/trio/issues/1924>`__)
661
662
663 Trio 0.18.0 (2021-01-11)
664 ------------------------
665
666 Features
667 ~~~~~~~~
668
669 - Add synchronous ``.close()`` methods and context manager (``with x``) support
670 for `.MemorySendChannel` and `.MemoryReceiveChannel`. (`#1797 <https://github.com/python-trio/trio/issues/1797>`__)
671
672
673 Bugfixes
674 ~~~~~~~~
675
676 - Previously, on Windows, Trio programs using thousands of sockets at the same time could trigger extreme slowdowns in the Windows kernel. Now, Trio works around this issue, so you should be able to use as many sockets as you want. (`#1280 <https://github.com/python-trio/trio/issues/1280>`__)
677 - :func:`trio.from_thread.run` no longer crashes the Trio run if it is
678 executed after the system nursery has been closed but before the run
679 has finished. Calls made at this time will now raise
680 `trio.RunFinishedError`. This fixes a regression introduced in
681 Trio 0.17.0. The window in question is only one scheduler tick long in
682 most cases, but may be longer if async generators need to be cleaned up. (`#1738 <https://github.com/python-trio/trio/issues/1738>`__)
683 - Fix a crash in pypy-3.7 (`#1765 <https://github.com/python-trio/trio/issues/1765>`__)
684 - Trio now avoids creating cyclic garbage as often. This should have a
685 minimal impact on most programs, but can slightly reduce how often the
686 cycle collector GC runs on CPython, which can reduce latency spikes. (`#1770 <https://github.com/python-trio/trio/issues/1770>`__)
687
688
689 Deprecations and removals
690 ~~~~~~~~~~~~~~~~~~~~~~~~~
691
692 - Remove deprecated ``max_refill_bytes`` from :class:`SSLStream`. (`#959 <https://github.com/python-trio/trio/issues/959>`__)
693 - Remove the deprecated ``tiebreaker`` argument to `trio.testing.wait_all_tasks_blocked`. (`#1558 <https://github.com/python-trio/trio/issues/1558>`__)
694 - Remove the deprecated ``trio.hazmat`` module. (`#1722 <https://github.com/python-trio/trio/issues/1722>`__)
695 - Stop allowing subclassing public classes. This behavior was deprecated in 0.15.0. (`#1726 <https://github.com/python-trio/trio/issues/1726>`__)
696
697
698 Trio 0.17.0 (2020-09-15)
699 ------------------------
700
701 Headline features
702 ~~~~~~~~~~~~~~~~~
703
704 - Trio now supports automatic :ref:`async generator finalization
705 <async-generators>`, so more async generators will work even if you
706 don't wrap them in ``async with async_generator.aclosing():``
707 blocks. Please see the documentation for important caveats; in
708 particular, yielding within a nursery or cancel scope remains
709 unsupported. (`#265 <https://github.com/python-trio/trio/issues/265>`__)
710
711
712 Features
713 ~~~~~~~~
714
715 - `trio.open_tcp_stream` has a new ``local_address=`` keyword argument
716 that can be used on machines with multiple IP addresses to control
717 which IP is used for the outgoing connection. (`#275 <https://github.com/python-trio/trio/issues/275>`__)
718 - If you pass a raw IP address into ``sendto``, it no longer spends any
719 time trying to resolve the hostname. If you're using UDP, this should
720 substantially reduce your per-packet overhead. (`#1595 <https://github.com/python-trio/trio/issues/1595>`__)
721 - `trio.lowlevel.checkpoint` is now much faster. (`#1613 <https://github.com/python-trio/trio/issues/1613>`__)
722 - We switched to a new, lower-overhead data structure to track upcoming
723 timeouts, which should make your programs faster. (`#1629 <https://github.com/python-trio/trio/issues/1629>`__)
724
725
726 Bugfixes
727 ~~~~~~~~
728
729 - On macOS and BSDs, explicitly close our wakeup socketpair when we're
730 done with it. (`#1621 <https://github.com/python-trio/trio/issues/1621>`__)
731 - Trio can now be imported when `sys.excepthook` is a `functools.partial` instance, which might occur in a
732 ``pytest-qt`` test function. (`#1630 <https://github.com/python-trio/trio/issues/1630>`__)
733 - The thread cache didn't release its reference to the previous job. (`#1638 <https://github.com/python-trio/trio/issues/1638>`__)
734 - On Windows, Trio now works around the buggy behavior of certain
735 Layered Service Providers (system components that can intercept
736 network activity) that are built on top of a commercially available
737 library called Komodia Redirector. This benefits users of products
738 such as Astrill VPN and Qustodio parental controls. Previously, Trio
739 would crash on startup when run on a system where such a product was
740 installed. (`#1659 <https://github.com/python-trio/trio/issues/1659>`__)
741
742
743 Deprecations and removals
744 ~~~~~~~~~~~~~~~~~~~~~~~~~
745
746 - Remove ``wait_socket_*``, ``notify_socket_closing``, ``notify_fd_closing``, ``run_sync_in_worker_thread`` and ``current_default_worker_thread_limiter``. They were deprecated in 0.12.0. (`#1596 <https://github.com/python-trio/trio/issues/1596>`__)
747
748
749 Miscellaneous internal changes
750 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
751
752 - When using :ref:`instruments <instrumentation>`, you now only "pay for what you use":
753 if there are no instruments installed that override a particular hook such as
754 :meth:`~trio.abc.Instrument.before_task_step`, then Trio doesn't waste any effort
755 on checking its instruments when the event corresponding to that hook occurs.
756 Previously, installing any instrument would incur all the instrumentation overhead,
757 even for hooks no one was interested in. (`#1340 <https://github.com/python-trio/trio/issues/1340>`__)
758
759
760 Trio 0.16.0 (2020-06-10)
761 ------------------------
762
763 Headline features
764 ~~~~~~~~~~~~~~~~~
765
766 - If you want to use Trio, but are stuck with some other event loop like
767 Qt or PyGame, then good news: now you can have both. For details, see:
768 :ref:`guest-mode`. (`#399 <https://github.com/python-trio/trio/issues/399>`__)
769
770
771 Features
772 ~~~~~~~~
773
774 - To speed up `trio.to_thread.run_sync`, Trio now caches and reuses
775 worker threads.
776
777 And in case you have some exotic use case where you need to spawn
778 threads manually, but want to take advantage of Trio's cache, you can
779 do that using the new `trio.lowlevel.start_thread_soon`. (`#6 <https://github.com/python-trio/trio/issues/6>`__)
780 - Tasks spawned with `nursery.start() <trio.Nursery.start>` aren't treated as
781 direct children of their nursery until they call ``task_status.started()``.
782 This is visible through the task tree introspection attributes such as
783 `Task.parent_nursery <trio.lowlevel.Task.parent_nursery>`. Sometimes, though,
784 you want to know where the task is going to wind up, even if it hasn't finished
785 initializing yet. To support this, we added a new attribute
786 `Task.eventual_parent_nursery <trio.lowlevel.Task.eventual_parent_nursery>`.
787 For a task spawned with :meth:`~trio.Nursery.start` that hasn't yet called
788 ``started()``, this is the nursery that the task was nominally started in,
789 where it will be running once it finishes starting up. In all other cases,
790 it is ``None``. (`#1558 <https://github.com/python-trio/trio/issues/1558>`__)
791
792
793 Bugfixes
794 ~~~~~~~~
795
796 - Added a helpful error message if an async function is passed to `trio.to_thread.run_sync`. (`#1573 <https://github.com/python-trio/trio/issues/1573>`__)
797
798
799 Deprecations and removals
800 ~~~~~~~~~~~~~~~~~~~~~~~~~
801
802 - Remove ``BlockingTrioPortal``: it was deprecated in 0.12.0. (`#1574 <https://github.com/python-trio/trio/issues/1574>`__)
803 - The ``tiebreaker`` argument to `trio.testing.wait_all_tasks_blocked`
804 has been deprecated. This is a highly obscure feature that was
805 probably never used by anyone except `trio.testing.MockClock`, and
806 `~trio.testing.MockClock` doesn't need it anymore. (`#1587 <https://github.com/python-trio/trio/issues/1587>`__)
807 - Remove the deprecated ``trio.ssl`` and ``trio.subprocess`` modules. (`#1594 <https://github.com/python-trio/trio/issues/1594>`__)
808
809
810 Miscellaneous internal changes
811 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
812
813 - We refactored `trio.testing.MockClock` so that it no longer needs to
814 run an internal task to manage autojumping. This should be mostly
815 invisible to users, but there is one semantic change: the interaction
816 between `trio.testing.wait_all_tasks_blocked` and the autojump clock
817 was fixed. Now, the autojump will always wait until after all
818 `~trio.testing.wait_all_tasks_blocked` calls have finished before
819 firing, instead of it depending on which threshold values you passed. (`#1587 <https://github.com/python-trio/trio/issues/1587>`__)
820
821
822 Trio 0.15.1 (2020-05-22)
823 ------------------------
824
825 Bugfixes
826 ~~~~~~~~
827
828 - Fix documentation build. (This must be a new release tag to get readthedocs
829 "stable" to include the changes from 0.15.0.)
830
831 - Added a helpful error message if an async function is passed to `trio.from_thread.run_sync` or a sync function to `trio.from_thread.run`. (`#1244 <https://github.com/python-trio/trio/issues/1244>`__)
832
833
834 Trio 0.15.0 (2020-05-19)
835 ------------------------
836
837 Features
838 ~~~~~~~~
839
840 - Previously, when `trio.run_process` was cancelled, it always killed
841 the subprocess immediately. Now, on Unix, it first gives the process a
842 chance to clean up by sending ``SIGTERM``, and only escalates to
843 ``SIGKILL`` if the process is still running after 5 seconds. But if
844 you prefer the old behavior, or want to adjust the timeout, then don't
845 worry: you can now pass a custom ``deliver_cancel=`` argument to
846 define your own process killing policy. (`#1104 <https://github.com/python-trio/trio/issues/1104>`__)
847 - It turns out that creating a subprocess can block the parent process
848 for a surprisingly long time. So ``trio.open_process`` now uses a worker
849 thread to avoid blocking the event loop. (`#1109 <https://github.com/python-trio/trio/issues/1109>`__)
850 - We've added FreeBSD to the list of platforms we support and test on. (`#1118 <https://github.com/python-trio/trio/issues/1118>`__)
851 - On Linux kernels v5.3 or newer, `trio.Process.wait` now uses `the
852 pidfd API <https://lwn.net/Articles/794707/>`__ to track child
853 processes. This shouldn't have any user-visible change, but it makes
854 working with subprocesses faster and use less memory. (`#1241 <https://github.com/python-trio/trio/issues/1241>`__)
855 - The `trio.Process.returncode` attribute is now automatically updated
856 as needed, instead of only when you call `~trio.Process.poll` or
857 `~trio.Process.wait`. Also, ``repr(process_object)`` now always
858 contains up-to-date information about the process status. (`#1315 <https://github.com/python-trio/trio/issues/1315>`__)
859
860
861 Bugfixes
862 ~~~~~~~~
863
864 - On Ubuntu systems, the system Python includes a custom
865 unhandled-exception hook to perform `crash reporting
866 <https://wiki.ubuntu.com/Apport>`__. Unfortunately, Trio wants to use
867 the same hook to print nice ``MultiError`` tracebacks, causing a
868 conflict. Previously, Trio would detect the conflict, print a warning,
869 and you just wouldn't get nice ``MultiError`` tracebacks. Now, Trio has
870 gotten clever enough to integrate its hook with Ubuntu's, so the two
871 systems should Just Work together. (`#1065 <https://github.com/python-trio/trio/issues/1065>`__)
872 - Fixed an over-strict test that caused failures on Alpine Linux.
873 Started testing against Alpine in CI. (`#1499 <https://github.com/python-trio/trio/issues/1499>`__)
874 - Calling `open_signal_receiver` with no arguments used to succeed without listening for any signals. This was confusing, so now it raises TypeError instead. (`#1526 <https://github.com/python-trio/trio/issues/1526>`__)
875
876
877 Deprecations and Removals
878 ~~~~~~~~~~~~~~~~~~~~~~~~~
879
880 - Remove support for Python 3.5. (`#75 <https://github.com/python-trio/trio/issues/75>`__)
881 - It turns out that everyone got confused by the name ``trio.hazmat``.
882 So that name has been deprecated, and the new name is
883 :mod:`trio.lowlevel`. (`#476 <https://github.com/python-trio/trio/issues/476>`__)
884 - Most of the public classes that Trio exports – like `trio.Lock`,
885 `trio.SocketStream`, and so on – weren't designed with subclassing in
886 mind. And we've noticed that some users were trying to subclass them
887 anyway, and ending up with fragile code that we're likely to
888 accidentally break in the future, or else be stuck unable to make
889 changes for fear of breaking subclasses.
890
891 There are also some classes that were explicitly designed to be
892 subclassed, like the ones in ``trio.abc``. Subclassing these is still
893 supported. However, for all other classes, attempts to subclass will
894 now raise a deprecation warning, and in the future will raise an
895 error.
896
897 If this causes problems for you, feel free to drop by our `chat room
898 <https://gitter.im/python-trio/general>`__ or file a bug, to discuss
899 alternatives or make a case for why some particular class should be
900 designed to support subclassing. (`#1044 <https://github.com/python-trio/trio/issues/1044>`__)
901 - If you want to create a `trio.Process` object, you now have to call
902 ``trio.open_process``; calling ``trio.Process()`` directly was
903 deprecated in v0.12.0 and has now been removed. (`#1109 <https://github.com/python-trio/trio/issues/1109>`__)
904 - Remove ``clear`` method on `trio.Event`: it was deprecated in 0.12.0. (`#1498 <https://github.com/python-trio/trio/issues/1498>`__)
905
906
907 Trio 0.14.0 (2020-04-27)
908 ------------------------
909
910 Features
911 ~~~~~~~~
912
913 - If you're using Trio's low-level interfaces like
914 `trio.hazmat.wait_readable <trio.lowlevel.wait_readable>` or similar, and then you close a socket or
915 file descriptor, you're supposed to call `trio.hazmat.notify_closing
916 <trio.lowlevel.notify_closing>`
917 first so Trio can clean up properly. But what if you forget? In the
918 past, Trio would tend to either deadlock or explode spectacularly.
919 Now, it's much more robust to this situation, and should generally
920 survive. (But note that "survive" is not the same as "give you the
921 results you were expecting", so you should still call
922 `~trio.lowlevel.notify_closing` when appropriate. This is about harm
923 reduction and making it easier to debug this kind of mistake, not
924 something you should rely on.)
925
926 If you're using higher-level interfaces outside of the `trio.hazmat <trio.lowlevel>`
927 module, then you don't need to worry about any of this; those
928 interfaces already take care of calling `~trio.lowlevel.notify_closing`
929 for you. (`#1272 <https://github.com/python-trio/trio/issues/1272>`__)
930
931
932 Bugfixes
933 ~~~~~~~~
934
935 - A bug related to the following methods has been introduced in version 0.12.0:
936
937 - `trio.Path.iterdir`
938 - `trio.Path.glob`
939 - `trio.Path.rglob`
940
941 The iteration of the blocking generators produced by pathlib was performed in
942 the trio thread. With this fix, the previous behavior is restored: the blocking
943 generators are converted into lists in a thread dedicated to blocking IO calls. (`#1308 <https://github.com/python-trio/trio/issues/1308>`__)
944
945
946 Deprecations and Removals
947 ~~~~~~~~~~~~~~~~~~~~~~~~~
948
949 - Deprecate Python 3.5 (`#1408 <https://github.com/python-trio/trio/pull/1408>`__)
950 - Remove ``trio.open_cancel_scope`` which was deprecated in 0.11.0. (`#1458 <https://github.com/python-trio/trio/issues/1458>`__)
951
952
953 Trio 0.13.0 (2019-11-02)
954 ------------------------
955
956 Features
957 ~~~~~~~~
958
959 - On Windows, the `IOCP subsystem
960 <https://docs.microsoft.com/en-us/windows/win32/fileio/i-o-completion-ports>`__
961 is generally the best way to implement async I/O operations – but it's
962 historically been weak at providing ``select``\-style readiness
963 notifications, like `trio.hazmat.wait_readable <trio.lowlevel.wait_readable>` and
964 `~trio.lowlevel.wait_writable`. We aren't willing to give those up, so
965 previously Trio's Windows backend used a hybrid of ``select`` + IOCP.
966 This was complex, slow, and had `limited scalability
967 <https://github.com/python-trio/trio/issues/3>`__.
968
969 Fortunately, we found a way to implement ``wait_*`` with IOCP, so
970 Trio's Windows backend has been completely rewritten, and now uses
971 IOCP exclusively. As a user, the only difference you should notice is
972 that Trio should now be faster on Windows, and can handle many more
973 sockets. This also simplified the code internally, which should allow
974 for more improvements in the future.
975
976 However, this is somewhat experimental, so if you use Windows then
977 please keep an eye out and let us know if you run into any problems! (`#52 <https://github.com/python-trio/trio/issues/52>`__)
978 - Use slots for memory channel state and statistics which should make memory channels slightly smaller and faster. (`#1195 <https://github.com/python-trio/trio/issues/1195>`__)
979
980
981 Bugfixes
982 ~~~~~~~~
983
984 - OpenSSL has a bug in its handling of TLS 1.3 session tickets that can
985 cause deadlocks or data loss in some rare edge cases. These edge cases
986 most frequently happen during tests. (Upstream bug reports: `openssl/openssl#7948
987 <https://github.com/openssl/openssl/issues/7948>`__, `openssl/openssl#7967
988 <https://github.com/openssl/openssl/issues/7967>`__.) `trio.SSLStream`
989 now works around this issue, so you don't have to worry about it. (`#819 <https://github.com/python-trio/trio/issues/819>`__)
990 - Trio now uses `signal.set_wakeup_fd` on all platforms. This is mostly
991 an internal refactoring with no user-visible effect, but in theory it
992 should fix a few extremely-rare race conditions on Unix that could
993 have caused signal delivery to be delayed. (`#109 <https://github.com/python-trio/trio/issues/109>`__)
994 - Trio no longer crashes when an async function is implemented in C or
995 Cython and then passed directly to `trio.run` or
996 ``nursery.start_soon``. (`#550 <https://github.com/python-trio/trio/issues/550>`__, `#1191 <https://github.com/python-trio/trio/issues/1191>`__)
997 - When a Trio task makes improper use of a non-Trio async library, Trio now causes an exception to be raised within the task at the point of the error, rather than abandoning the task and raising an error in its parent. This improves debuggability and resolves the `TrioInternalError` that would sometimes result from the old strategy. (`#552 <https://github.com/python-trio/trio/issues/552>`__)
998 - In 0.12.0 we deprecated ``trio.run_sync_in_worker_thread`` in favor of
999 `trio.to_thread.run_sync`. But, the deprecation message listed the
1000 wrong name for the replacement. The message now gives the correct name. (`#810 <https://github.com/python-trio/trio/issues/810>`__)
1001 - Fix regression introduced with cancellation changes in 0.12.0, where a
1002 `trio.CancelScope` which isn't cancelled could catch a propagating
1003 `trio.Cancelled` exception if shielding were changed while the
1004 cancellation was propagating. (`#1175 <https://github.com/python-trio/trio/issues/1175>`__)
1005 - Fix a crash that could happen when using ``MockClock`` with autojump
1006 enabled and a non-zero rate. (`#1190 <https://github.com/python-trio/trio/issues/1190>`__)
1007 - If you nest >1000 cancel scopes within each other, Trio now handles
1008 that gracefully instead of crashing with a ``RecursionError``. (`#1235 <https://github.com/python-trio/trio/issues/1235>`__)
1009 - Fixed the hash behavior of `trio.Path` to match `pathlib.Path`. Previously `trio.Path`'s hash was inherited from `object` instead of from `pathlib.PurePath`. Thus, hashing two `trio.Path`\'s or a `trio.Path` and a `pathlib.Path` with the same underlying path would yield different results. (`#1259 <https://github.com/python-trio/trio/issues/1259>`__)
1010
1011
1012 Trio 0.12.1 (2019-08-01)
1013 ------------------------
1014
1015 Bugfixes
1016 ~~~~~~~~
1017
1018 - In v0.12.0, we accidentally moved ``BlockingTrioPortal`` from ``trio``
1019 to ``trio.hazmat``. It's now been restored to its proper position.
1020 (It's still deprecated though, and will issue a warning if you use it.) (`#1167 <https://github.com/python-trio/trio/issues/1167>`__)
1021
1022
1023 Trio 0.12.0 (2019-07-31)
1024 ------------------------
1025
1026 Features
1027 ~~~~~~~~
1028
1029 - If you have a `~trio.abc.ReceiveStream` object, you can now use
1030 ``async for data in stream: ...`` instead of calling
1031 `~trio.abc.ReceiveStream.receive_some`. Each iteration gives an
1032 arbitrary sized chunk of bytes. And the best part is, the loop
1033 automatically exits when you reach EOF, so you don't have to check for
1034 it yourself anymore. Relatedly, you no longer need to pick a magic
1035 buffer size value before calling
1036 `~trio.abc.ReceiveStream.receive_some`; you can ``await
1037 stream.receive_some()`` with no arguments, and the stream will
1038 automatically pick a reasonable size for you. (`#959 <https://github.com/python-trio/trio/issues/959>`__)
1039 - Threading interfaces have been reworked:
1040 ``run_sync_in_worker_thread`` is now `trio.to_thread.run_sync`, and
1041 instead of ``BlockingTrioPortal``, use `trio.from_thread.run` and
1042 `trio.from_thread.run_sync`. What's neat about this is that these
1043 cooperate, so if you're in a thread created by `to_thread.run_sync`,
1044 it remembers which Trio created it, and you can call
1045 ``trio.from_thread.*`` directly without having to pass around a
1046 ``BlockingTrioPortal`` object everywhere. (`#810 <https://github.com/python-trio/trio/issues/810>`__)
1047 - We cleaned up the distinction between the "abstract channel interface"
1048 and the "memory channel" concrete implementation.
1049 `trio.abc.SendChannel` and `trio.abc.ReceiveChannel` have been slimmed
1050 down, `trio.MemorySendChannel` and `trio.MemoryReceiveChannel` are now
1051 public types that can be used in type hints, and there's a new
1052 `trio.abc.Channel` interface for future bidirectional channels. (`#719 <https://github.com/python-trio/trio/issues/719>`__)
1053 - Add :func:`trio.run_process` as a high-level helper for running a process
1054 and waiting for it to finish, like the standard :func:`subprocess.run` does. (`#822 <https://github.com/python-trio/trio/issues/822>`__)
1055 - On Linux, when wrapping a bare file descriptor in a Trio socket object,
1056 Trio now auto-detects the correct ``family``, ``type``, and ``protocol``.
1057 This is useful, for example, when implementing `systemd socket activation
1058 <http://0pointer.de/blog/projects/socket-activation.html>`__. (`#251 <https://github.com/python-trio/trio/issues/251>`__)
1059 - Trio sockets have a new method `~trio.socket.SocketType.is_readable` that allows
1060 you to check whether a socket is readable. This is useful for HTTP/1.1 clients. (`#760 <https://github.com/python-trio/trio/issues/760>`__)
1061 - We no longer use runtime code generation to dispatch core functions
1062 like `current_time`. Static analysis tools like mypy and pylint should
1063 now be able to recognize and analyze all of Trio's top-level functions
1064 (though some class attributes are still dynamic... we're working on it). (`#805 <https://github.com/python-trio/trio/issues/805>`__)
1065 - Add `trio.hazmat.FdStream <trio.lowlevel.FdStream>` for wrapping a Unix file descriptor as a `~trio.abc.Stream`. (`#829 <https://github.com/python-trio/trio/issues/829>`__)
1066 - Trio now gives a reasonable traceback and error message in most cases
1067 when its invariants surrounding cancel scope nesting have been
1068 violated. (One common source of such violations is an async generator
1069 that yields within a cancel scope.) The previous behavior was an
1070 inscrutable chain of TrioInternalErrors. (`#882 <https://github.com/python-trio/trio/issues/882>`__)
1071 - ``MultiError`` now defines its ``exceptions`` attribute in ``__init__()``
1072 to better support linters and code autocompletion. (`#1066 <https://github.com/python-trio/trio/issues/1066>`__)
1073 - Use ``__slots__`` in more places internally, which should make Trio slightly faster. (`#984 <https://github.com/python-trio/trio/issues/984>`__)
1074
1075
1076 Bugfixes
1077 ~~~~~~~~
1078
1079 - Destructor methods (``__del__``) are now protected against ``KeyboardInterrupt``. (`#676 <https://github.com/python-trio/trio/issues/676>`__)
1080 - The :class:`trio.Path` methods :meth:`~trio.Path.glob` and
1081 :meth:`~trio.Path.rglob` now return iterables of :class:`trio.Path`
1082 (not :class:`pathlib.Path`). (`#917 <https://github.com/python-trio/trio/issues/917>`__)
1083 - Inspecting the :attr:`~trio.CancelScope.cancel_called` attribute of a
1084 not-yet-exited cancel scope whose deadline is in the past now always
1085 returns ``True``, like you might expect. (Previously it would return
1086 ``False`` for not-yet-entered cancel scopes, and for active cancel
1087 scopes until the first checkpoint after their deadline expiry.) (`#958 <https://github.com/python-trio/trio/issues/958>`__)
1088 - The :class:`trio.Path` classmethods, :meth:`~trio.Path.home` and
1089 :meth:`~trio.Path.cwd`, are now async functions. Previously, a bug
1090 in the forwarding logic meant :meth:`~trio.Path.cwd` was synchronous
1091 and :meth:`~trio.Path.home` didn't work at all. (`#960 <https://github.com/python-trio/trio/issues/960>`__)
1092 - An exception encapsulated within a ``MultiError`` doesn't need to be
1093 hashable anymore.
1094
1095 .. note::
1096
1097 This is only supported if you are running python >= 3.6.4. You can
1098 refer to `this github PR <https://github.com/python/cpython/pull/4014>`_
1099 for details. (`#1005 <https://github.com/python-trio/trio/issues/1005>`__)
1100
1101
1102 Improved Documentation
1103 ~~~~~~~~~~~~~~~~~~~~~~
1104
1105 - To help any user reading through Trio's function implementations, start using public names (not _core) whenever possible. (`#1017 <https://github.com/python-trio/trio/issues/1017>`__)
1106
1107
1108 Deprecations and Removals
1109 ~~~~~~~~~~~~~~~~~~~~~~~~~
1110
1111 - The ``clear`` method on `trio.Event` has been deprecated. (`#637 <https://github.com/python-trio/trio/issues/637>`__)
1112 - ``BlockingTrioPortal`` has been deprecated in favor of the new
1113 `trio.from_thread`. (`#810
1114 <https://github.com/python-trio/trio/issues/810>`__)
1115 - ``run_sync_in_worker_thread`` is deprecated in favor of
1116 `trio.to_thread.run_sync`. (`#810
1117 <https://github.com/python-trio/trio/issues/810>`__)
1118 - ``current_default_worker_thread_limiter`` is deprecated in favor of
1119 `trio.to_thread.current_default_thread_limiter`. (`#810
1120 <https://github.com/python-trio/trio/issues/810>`__)
1121 - Give up on trying to have different low-level waiting APIs on Unix and
1122 Windows. All platforms now have `trio.hazmat.wait_readable <trio.lowlevel.wait_readable>`,
1123 `trio.hazmat.wait_writable <trio.lowlevel.wait_writable>`, and
1124 `trio.hazmat.notify_closing <trio.lowlevel.notify_closing>`. The old
1125 platform-specific synonyms ``wait_socket_*``,
1126 ``notify_socket_closing``, and ``notify_fd_closing`` have been
1127 deprecated. (`#878 <https://github.com/python-trio/trio/issues/878>`__)
1128 - It turns out that it's better to treat subprocess spawning as an async
1129 operation. Therefore, direct construction of `Process` objects has
1130 been deprecated. Use ``trio.open_process`` instead. (`#1109 <https://github.com/python-trio/trio/issues/1109>`__)
1131
1132
1133 Miscellaneous internal changes
1134 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1135
1136 - The plumbing of Trio's cancellation system has been substantially overhauled
1137 to improve performance and ease future planned improvements. Notably, there is
1138 no longer any internal concept of a "cancel stack", and checkpoints now take
1139 constant time regardless of the cancel scope nesting depth. (`#58 <https://github.com/python-trio/trio/issues/58>`__)
1140 - We've slightly relaxed our definition of which Trio operations act as
1141 :ref:`checkpoints <checkpoint-rule>`. A Trio async function that exits by
1142 throwing an exception is no longer guaranteed to execute a checkpoint;
1143 it might or might not. The rules are unchanged for async functions that
1144 don't exit with an exception, async iterators, and async context managers.
1145 :func:`trio.testing.assert_checkpoints` has been updated to reflect the
1146 new behavior: if its ``with`` block exits with an exception, no assertion
1147 is made. (`#474 <https://github.com/python-trio/trio/issues/474>`__)
1148 - Calling ``str`` on a :exc:`trio.Cancelled` exception object returns "Cancelled" instead of an empty string. (`#674 <https://github.com/python-trio/trio/issues/674>`__)
1149 - Change the default timeout in :func:`trio.open_tcp_stream` to 0.250 seconds, for consistency with RFC 8305. (`#762 <https://github.com/python-trio/trio/issues/762>`__)
1150 - On win32 we no longer set SO_EXCLUSIVEADDRUSE when binding a socket in :exc:`trio.open_tcp_listeners`. (`#928 <https://github.com/python-trio/trio/issues/928>`__)
1151 - Any attempt to inherit from `CancelScope` or `Nursery` now raises
1152 `TypeError`. (Trio has never been able to safely support subclassing
1153 here; this change just makes it more obvious.)
1154 Also exposed as public classes for type-checking, etc. (`#1021 <https://github.com/python-trio/trio/issues/1021>`__)
1155
1156
1157 Trio 0.11.0 (2019-02-09)
1158 ------------------------
1159
1160 Features
1161 ~~~~~~~~
1162
1163 - Add support for "unbound cancel scopes": you can now construct a
1164 :class:`trio.CancelScope` without entering its context, e.g., so you
1165 can pass it to another task which will use it to wrap some work that
1166 you want to be able to cancel from afar. (`#607 <https://github.com/python-trio/trio/issues/607>`__)
1167 - The test suite now passes with openssl v1.1.1. Unfortunately this
1168 required temporarily disabling TLS v1.3 during tests; see openssl bugs
1169 `#7948 <https://github.com/openssl/openssl/issues/7948>`__ and `#7967
1170 <https://github.com/openssl/openssl/issues/7967>`__. We believe TLS
1171 v1.3 should work in most real use cases, but will be monitoring the
1172 situation. (`#817 <https://github.com/python-trio/trio/issues/817>`__)
1173 - Add :attr:`trio.Process.stdio`, which is a :class:`~trio.StapledStream` of
1174 :attr:`~trio.Process.stdin` and :attr:`~trio.Process.stdout` if both of those
1175 are available, and ``None`` otherwise. This is intended to make it more
1176 ergonomic to speak a back-and-forth protocol with a subprocess. (`#862 <https://github.com/python-trio/trio/issues/862>`__)
1177 - :class:`trio.Process` on POSIX systems no longer accepts the error-prone
1178 combination of ``shell=False`` with a ``command`` that's a single string,
1179 or ``shell=True`` with a ``command`` that's a sequence of strings.
1180 These forms are accepted by the underlying :class:`subprocess.Popen`
1181 constructor but don't do what most users expect. Also, added an explanation
1182 of :ref:`quoting <subprocess-quoting>` to the documentation. (`#863 <https://github.com/python-trio/trio/issues/863>`__)
1183 - Added an internal mechanism for pytest-trio's
1184 `Hypothesis <https://hypothesis.readthedocs.io>`__ integration
1185 to make the task scheduler reproducible and avoid flaky tests. (`#890 <https://github.com/python-trio/trio/issues/890>`__)
1186 - :class:`~trio.abc.SendChannel`, :class:`~trio.abc.ReceiveChannel`, :class:`~trio.abc.Listener`,
1187 and :func:`~trio.open_memory_channel` can now be referenced using a generic type parameter
1188 (the type of object sent over the channel or produced by the listener) using :pep:`484` syntax:
1189 ``trio.abc.SendChannel[bytes]``, ``trio.abc.Listener[trio.SocketStream]``,
1190 ``trio.open_memory_channel[MyMessage](5)``, etc. The added type information does not change
1191 the runtime semantics, but permits better integration with external static type checkers. (`#908 <https://github.com/python-trio/trio/issues/908>`__)
1192
1193
1194 Bugfixes
1195 ~~~~~~~~
1196
1197 - Fixed several bugs in the new Unix subprocess pipe support, where
1198 (a) operations on a closed pipe could accidentally affect another
1199 unrelated pipe due to internal file-descriptor reuse, (b) in very rare
1200 circumstances, two tasks calling ``send_all`` on the same pipe at the
1201 same time could end up with intermingled data instead of a
1202 :exc:`BusyResourceError`. (`#661 <https://github.com/python-trio/trio/issues/661>`__)
1203 - Stop :func:`trio.open_tcp_listeners` from crashing on systems that have
1204 disabled IPv6. (`#853 <https://github.com/python-trio/trio/issues/853>`__)
1205 - Fixed support for multiple tasks calling :meth:`trio.Process.wait`
1206 simultaneously; on kqueue platforms it would previously raise an exception. (`#854 <https://github.com/python-trio/trio/issues/854>`__)
1207 - :exc:`trio.Cancelled` exceptions now always propagate until they reach
1208 the outermost unshielded cancelled scope, even if more cancellations
1209 occur or shielding is changed between when the :exc:`~trio.Cancelled`
1210 is delivered and when it is caught. (`#860 <https://github.com/python-trio/trio/issues/860>`__)
1211 - If you have a :class:`SocketStream` that's already been closed, then
1212 ``await socket_stream.send_all(b"")`` will now correctly raise
1213 :exc:`ClosedResourceError`. (`#874 <https://github.com/python-trio/trio/issues/874>`__)
1214 - Simplified the Windows subprocess pipe ``send_all`` code, and in the
1215 process fixed a theoretical bug where closing a pipe at just the wrong
1216 time could produce errors or cause data to be redirected to the wrong
1217 pipe. (`#883 <https://github.com/python-trio/trio/issues/883>`__)
1218
1219
1220 Deprecations and Removals
1221 ~~~~~~~~~~~~~~~~~~~~~~~~~
1222
1223 - Deprecate ``trio.open_cancel_scope`` in favor of :class:`trio.CancelScope`,
1224 which more clearly reflects that creating a cancel scope is just an ordinary
1225 object construction and does not need to be immediately paired with entering it. (`#607 <https://github.com/python-trio/trio/issues/607>`__)
1226 - The submodules ``trio.ssl`` and ``trio.subprocess`` are now deprecated.
1227 Their nontrivial contents (:class:`~trio.Process`, :class:`~trio.SSLStream`,
1228 and :class:`~trio.SSLListener`) have been moved to the main :mod:`trio`
1229 namespace. For the numerous constants, exceptions, and other helpers
1230 that were previously reexported from the standard :mod:`ssl` and
1231 :mod:`subprocess` modules, you should now use those modules directly. (`#852 <https://github.com/python-trio/trio/issues/852>`__)
1232 - Remove all the APIs deprecated in 0.9.0 or earlier (``trio.Queue``,
1233 ``trio.catch_signals()``, ``trio.BrokenStreamError``, and
1234 ``trio.ResourceBusyError``), except for ``trio.hazmat.UnboundedQueue``,
1235 which stays for now since it is used by the obscure lowlevel functions
1236 ``monitor_completion_queue()`` and ``monitor_kevent()``. (`#918 <https://github.com/python-trio/trio/issues/918>`__)
1237
1238
1239 Miscellaneous internal changes
1240 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1241
1242 - Entering a cancel scope whose deadline is in the past now immediately
1243 cancels it, so :exc:`~trio.Cancelled` will be raised by the first
1244 checkpoint in the cancel scope rather than the second one.
1245 This also affects constructs like ``with trio.move_on_after(0):``. (`#320 <https://github.com/python-trio/trio/issues/320>`__)
1246
1247
1248 Trio 0.10.0 (2019-01-07)
1249 ------------------------
1250
1251 Features
1252 ~~~~~~~~
1253
1254 - Initial :ref:`subprocess support <subprocess>`. Add
1255 :class:`trio.subprocess.Process <trio.Process>`, an async wrapper around the stdlib
1256 :class:`subprocess.Popen` class, which permits spawning subprocesses and
1257 communicating with them over standard Trio streams. ``trio.subprocess``
1258 also reexports all the stdlib :mod:`subprocess` exceptions and constants for
1259 convenience. (`#4 <https://github.com/python-trio/trio/issues/4>`__)
1260 - You can now create an unbounded :class:`CapacityLimiter` by initializing with
1261 `math.inf` (`#618 <https://github.com/python-trio/trio/issues/618>`__)
1262 - New :mod:`trio.hazmat <trio.lowlevel>` features to allow cleanly switching live coroutine
1263 objects between Trio and other coroutine runners. Frankly, we're not even
1264 sure this is a good idea, but we want to `try it out in trio-asyncio
1265 <https://github.com/python-trio/trio-asyncio/issues/42>`__, so here we are.
1266 For details see :ref:`live-coroutine-handoff`. (`#649
1267 <https://github.com/python-trio/trio/issues/649>`__)
1268
1269
1270 Bugfixes
1271 ~~~~~~~~
1272
1273 - Fixed a race condition on macOS, where Trio's TCP listener would crash if an
1274 incoming TCP connection was closed before the listener had a chance to accept
1275 it. (`#609 <https://github.com/python-trio/trio/issues/609>`__)
1276 - :func:`trio.open_tcp_stream` has been refactored to clean up unsuccessful
1277 connection attempts more reliably. (`#809
1278 <https://github.com/python-trio/trio/issues/809>`__)
1279
1280
1281 Deprecations and Removals
1282 ~~~~~~~~~~~~~~~~~~~~~~~~~
1283
1284 - Remove the APIs deprecated in 0.5.0. (``ClosedStreamError``,
1285 ``ClosedListenerError``, ``Result``) (`#812
1286 <https://github.com/python-trio/trio/issues/812>`__)
1287
1288
1289 Miscellaneous internal changes
1290 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1291
1292 - There are a number of methods on :class:`trio.ssl.SSLStream <trio.SSLStream>`
1293 that report information about the negotiated TLS connection, like
1294 ``selected_alpn_protocol``, and thus cannot succeed until after the handshake
1295 has been performed. Previously, we returned None from these methods, like the
1296 stdlib :mod:`ssl` module does, but this is confusing, because that can also
1297 be a valid return value. Now we raise :exc:`trio.ssl.NeedHandshakeError
1298 <trio.NeedHandshakeError>`
1299 instead. (`#735 <https://github.com/python-trio/trio/issues/735>`__)
1300
1301
1302 Trio 0.9.0 (2018-10-12)
1303 -----------------------
1304
1305 Features
1306 ~~~~~~~~
1307
1308 - New and improved APIs for inter-task communication:
1309 :class:`trio.abc.SendChannel`, :class:`trio.abc.ReceiveChannel`, and
1310 :func:`trio.open_memory_channel` (which replaces ``trio.Queue``). This
1311 interface uses separate "sender" and "receiver" objects, for
1312 consistency with other communication interfaces like
1313 :class:`~trio.abc.Stream`. Also, the two objects can now be closed
1314 individually, making it much easier to gracefully shut down a channel.
1315 Also, check out the nifty ``clone`` API to make it easy to manage
1316 shutdown in multiple-producer/multiple-consumer scenarios. Also, the
1317 API has been written to allow for future channel implementations that
1318 send objects across process boundaries. Also, it supports unbounded
1319 buffering if you really need it. Also, help I can't stop writing also.
1320 See :ref:`channels` for more details. (`#497
1321 <https://github.com/python-trio/trio/issues/497>`__)
1322
1323
1324 Deprecations and Removals
1325 ~~~~~~~~~~~~~~~~~~~~~~~~~
1326
1327 - ``trio.Queue`` and ``trio.hazmat.UnboundedQueue`` have been deprecated, in
1328 favor of :func:`trio.open_memory_channel`. (`#497
1329 <https://github.com/python-trio/trio/issues/497>`__)
1330
1331
1332 Trio 0.8.0 (2018-10-01)
1333 -----------------------
1334
1335 Features
1336 ~~~~~~~~
1337
1338 - Trio's default internal clock is now based on :func:`time.perf_counter`
1339 instead of :func:`time.monotonic`. This makes time-keeping more precise on
1340 Windows, and has no effect on other platforms. (`#33
1341 <https://github.com/python-trio/trio/issues/33>`__)
1342 - Reworked :mod:`trio`, :mod:`trio.testing`, and :mod:`trio.socket` namespace
1343 construction, making them more understandable by static analysis tools. This
1344 should improve tab completion in editors, reduce false positives from pylint,
1345 and is a first step towards providing type hints. (`#542
1346 <https://github.com/python-trio/trio/issues/542>`__)
1347
1348
1349 Deprecations and Removals
1350 ~~~~~~~~~~~~~~~~~~~~~~~~~
1351
1352 - ``ResourceBusyError`` is now a deprecated alias for the new
1353 :exc:`BusyResourceError`, and ``BrokenStreamError`` is a deprecated alias for
1354 the new :exc:`BrokenResourceError`. (`#620
1355 <https://github.com/python-trio/trio/issues/620>`__)
1356
1357
1358 Trio 0.7.0 (2018-09-03)
1359 -----------------------
1360
1361 Features
1362 ~~~~~~~~
1363
1364 - The length of typical exception traces coming from Trio has been
1365 greatly reduced. This was done by eliminating many of the exception
1366 frames related to details of the implementation. For examples, see
1367 the `blog post
1368 <https://vorpus.org/blog/beautiful-tracebacks-in-trio-v070/>`__.
1369 (`#56 <https://github.com/python-trio/trio/issues/56>`__)
1370 - New and improved signal catching API: :func:`open_signal_receiver`. (`#354
1371 <https://github.com/python-trio/trio/issues/354>`__)
1372 - The low level ``trio.hazmat.wait_socket_readable``,
1373 ``wait_socket_writable``, and
1374 ``notify_socket_close`` now work on bare socket descriptors,
1375 instead of requiring a :func:`socket.socket` object. (`#400
1376 <https://github.com/python-trio/trio/issues/400>`__)
1377 - If you're using :func:`trio.hazmat.wait_task_rescheduled <trio.lowlevel.wait_task_rescheduled>` and other low-level
1378 routines to implement a new sleeping primitive, you can now use the new
1379 :data:`trio.hazmat.Task.custom_sleep_data <trio.lowlevel.Task.custom_sleep_data>` attribute to pass arbitrary data
1380 between the sleeping task, abort function, and waking task. (`#616
1381 <https://github.com/python-trio/trio/issues/616>`__)
1382
1383
1384 Bugfixes
1385 ~~~~~~~~
1386
1387 - Prevent crashes when used with Sentry (raven-python). (`#599
1388 <https://github.com/python-trio/trio/issues/599>`__)
1389 - The nursery context manager was rewritten to avoid use of
1390 ``@asynccontextmanager`` and ``@async_generator``. This reduces extraneous frames
1391 in exception traces and addresses bugs regarding `StopIteration` and
1392 `StopAsyncIteration` exceptions not propagating correctly. (`#612
1393 <https://github.com/python-trio/trio/issues/612>`__)
1394 - Updates the formatting of exception messages raised by
1395 :func:`trio.open_tcp_stream` to correctly handle a hostname passed in as
1396 bytes, by converting the hostname to a string. (`#633
1397 <https://github.com/python-trio/trio/issues/633>`__)
1398
1399
1400 Deprecations and Removals
1401 ~~~~~~~~~~~~~~~~~~~~~~~~~
1402
1403 - ``trio.catch_signals`` has been deprecated in favor of
1404 :func:`open_signal_receiver`. The main differences are: it takes
1405 \*-args now to specify the list of signals (so
1406 ``open_signal_receiver(SIGINT)`` instead of
1407 ``catch_signals({SIGINT})``), and, the async iterator now yields
1408 individual signals, instead of "batches" (`#354
1409 <https://github.com/python-trio/trio/issues/354>`__)
1410 - Remove all the APIs deprecated in 0.3.0 and 0.4.0. (`#623
1411 <https://github.com/python-trio/trio/issues/623>`__)
1412
1413
1414 Trio 0.6.0 (2018-08-13)
1415 -----------------------
1416
1417 Features
1418 ~~~~~~~~
1419
1420 - Add :func:`trio.hazmat.WaitForSingleObject <trio.lowlevel.WaitForSingleObject>` async function to await Windows
1421 handles. (`#233 <https://github.com/python-trio/trio/issues/233>`__)
1422 - The `sniffio <https://github.com/python-trio/sniffio>`__ library can now
1423 detect when Trio is running. (`#572
1424 <https://github.com/python-trio/trio/issues/572>`__)
1425
1426
1427 Bugfixes
1428 ~~~~~~~~
1429
1430 - Make trio.socket._SocketType.connect *always* close the socket on
1431 cancellation (`#247 <https://github.com/python-trio/trio/issues/247>`__)
1432 - Fix a memory leak in :class:`trio.CapacityLimiter`, that could occur when
1433 ``acquire`` or ``acquire_on_behalf_of`` was cancelled. (`#548
1434 <https://github.com/python-trio/trio/issues/548>`__)
1435 - Some version of macOS have a buggy ``getaddrinfo`` that was causing spurious
1436 test failures; we now detect those systems and skip the relevant test when
1437 found. (`#580 <https://github.com/python-trio/trio/issues/580>`__)
1438 - Prevent crashes when used with Sentry (raven-python). (`#599
1439 <https://github.com/python-trio/trio/issues/599>`__)
1440
1441
1442 Trio 0.5.0 (2018-07-20)
1443 -----------------------
1444
1445 Features
1446 ~~~~~~~~
1447
1448 - Suppose one task is blocked trying to use a resource – for example, reading
1449 from a socket – and while it's doing this, another task closes the resource.
1450 Previously, this produced undefined behavior. Now, closing a resource causes
1451 pending operations on that resource to terminate immediately with a
1452 :exc:`ClosedResourceError`. ``ClosedStreamError`` and ``ClosedListenerError``
1453 are now aliases for :exc:`ClosedResourceError`, and deprecated. For this to
1454 work, Trio needs to know when a resource has been closed. To facilitate this,
1455 new functions have been added: ``trio.hazmat.notify_fd_close`` and
1456 ``trio.hazmat.notify_socket_close``. If you're using Trio's built-in
1457 wrappers like :class:`~trio.SocketStream` or :mod:`trio.socket`, then you don't
1458 need to worry about this, but if you're using the low-level functions like
1459 :func:`trio.hazmat.wait_readable <trio.lowlevel.wait_readable>`, you should make sure to call these
1460 functions at appropriate times. (`#36
1461 <https://github.com/python-trio/trio/issues/36>`__)
1462 - Tasks created by :func:`~trio.lowlevel.spawn_system_task` now no longer inherit
1463 the creator's :mod:`contextvars` context, instead using one created at
1464 :func:`~trio.run`. (`#289
1465 <https://github.com/python-trio/trio/issues/289>`__)
1466 - Add support for ``trio.Queue`` with ``capacity=0``. Queue's implementation
1467 is also faster now. (`#473
1468 <https://github.com/python-trio/trio/issues/473>`__)
1469 - Switch to using standalone `Outcome
1470 <https://github.com/python-trio/outcome>`__ library for Result objects.
1471 (`#494 <https://github.com/python-trio/trio/issues/494>`__)
1472
1473 Deprecations and Removals
1474 ~~~~~~~~~~~~~~~~~~~~~~~~~
1475
1476 - ``trio.hazmat.Result``, ``trio.hazmat.Value`` and
1477 ``trio.hazmat.Error`` have been replaced by the equivalent
1478 classes in the `Outcome <https://github.com/python-trio/outcome>`__ library.
1479
1480 Trio 0.4.0 (2018-04-10)
1481 -----------------------
1482
1483 Features
1484 ~~~~~~~~
1485
1486 - Add unix client socket support. (`#401
1487 <https://github.com/python-trio/trio/issues/401>`__)
1488 - Add support for :mod:`contextvars` (see :ref:`task-local storage
1489 <task-local-storage>`), and add :class:`trio.hazmat.RunVar <trio.lowlevel.RunVar>` as a similar API
1490 for run-local variables. Deprecate ``trio.TaskLocal`` and
1491 ``trio.hazmat.RunLocal`` in favor of these new APIs. (`#420
1492 <https://github.com/python-trio/trio/issues/420>`__)
1493 - Add :func:`trio.hazmat.current_root_task <trio.lowlevel.current_root_task>` to get the root task. (`#452
1494 <https://github.com/python-trio/trio/issues/452>`__)
1495
1496
1497 Bugfixes
1498 ~~~~~~~~
1499
1500 - Fix KeyboardInterrupt handling when threading state has been modified by a
1501 3rd-party library. (`#461
1502 <https://github.com/python-trio/trio/issues/461>`__)
1503
1504
1505 Deprecations and Removals
1506 ~~~~~~~~~~~~~~~~~~~~~~~~~
1507
1508 - Attempting to explicitly raise :exc:`trio.Cancelled` will cause a :exc:`RuntimeError`.
1509 :meth:`cancel_scope.cancel() <trio.CancelScope.cancel>` should
1510 be used instead. (`#342 <https://github.com/python-trio/trio/issues/342>`__)
1511
1512
1513 Miscellaneous internal changes
1514 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1515
1516 - Simplify implementation of primitive traps like :func:`~trio.lowlevel.wait_task_rescheduled`
1517 (`#395 <https://github.com/python-trio/trio/issues/395>`__)
1518
1519
1520 Trio 0.3.0 (2017-12-28)
1521 -----------------------
1522
1523 Features
1524 ~~~~~~~~
1525
1526 - **Simplified nurseries**: In Trio, the rule used to be that "parenting is a
1527 full time job", meaning that after a task opened a nursery and spawned some
1528 children into it, it had to immediately block in ``__aexit__`` to supervise
1529 the new children, or else exception propagation wouldn't work. Also there was
1530 some elaborate machinery to let you replace this supervision logic with your
1531 own custom supervision logic. Thanks to new advances in task-rearing
1532 technology, **parenting is no longer a full time job!** Now the supervision
1533 happens automatically in the background, and essentially the body of a
1534 ``async with trio.open_nursery()`` block acts just like a task running inside
1535 the nursery. This is important: it makes it possible for libraries to
1536 abstract over nursery creation. For example, if you have a Websocket library
1537 that needs to run a background task to handle Websocket pings, you can now do
1538 that with ``async with open_websocket(...) as ws: ...``, and that can run a
1539 task in the background without your users having to worry about parenting it.
1540 And don't worry, you can still make custom supervisors; it turned out all
1541 that spiffy machinery was actually redundant and didn't provide much value.
1542 (`#136 <https://github.com/python-trio/trio/issues/136>`__)
1543 - Trio socket methods like ``bind`` and ``connect`` no longer require
1544 "pre-resolved" numeric addresses; you can now pass regular hostnames and Trio
1545 will implicitly resolve them for you. (`#377
1546 <https://github.com/python-trio/trio/issues/377>`__)
1547
1548
1549 Bugfixes
1550 ~~~~~~~~
1551
1552 - Fixed some corner cases in Trio socket method implicit name resolution to
1553 better match stdlib behavior. Example: ``sock.bind(("", port))`` now binds to
1554 the wildcard address instead of raising an error. (`#277
1555 <https://github.com/python-trio/trio/issues/277>`__)
1556
1557
1558 Deprecations and Removals
1559 ~~~~~~~~~~~~~~~~~~~~~~~~~
1560
1561 - Removed everything that was deprecated in 0.2.0; see the 0.2.0
1562 release notes below for details.
1563 - As was foretold in the v0.2.0 release notes, the ``bind`` method on Trio
1564 sockets is now async. Please update your calls or – better yet – switch to
1565 our shiny new high-level networking API, like :func:`serve_tcp`. (`#241
1566 <https://github.com/python-trio/trio/issues/241>`__)
1567 - The ``resolve_local_address`` and ``resolve_remote_address`` methods
1568 on Trio sockets have been deprecated; these are unnecessary now that
1569 you can just pass your hostnames directly to the socket methods you
1570 want to use. (`#377
1571 <https://github.com/python-trio/trio/issues/377>`__)
1572
1573
1574 Trio 0.2.0 (2017-12-06)
1575 -----------------------
1576
1577 Trio 0.2.0 contains changes from 14 contributors, and brings major new
1578 features and bug fixes, as well as a number of deprecations and a very
1579 small number of backwards incompatible changes. We anticipate that
1580 these should be easy to adapt to, but make sure to read about them
1581 below, and if you're using Trio then remember to `read and subscribe
1582 to issue #1 <https://github.com/python-trio/trio/issues/1>`__.
1583
1584
1585 Highlights
1586 ~~~~~~~~~~
1587
1588 * Added a comprehensive API for async filesystem I/O: see
1589 :ref:`async-file-io` (`gh-20
1590 <https://github.com/python-trio/trio/pull/20>`__)
1591
1592 * The new nursery :meth:`~Nursery.start` method makes it
1593 easy to perform controlled start-up of long-running tasks. For
1594 example, given an appropriate ``http_server_on_random_open_port``
1595 function, you could write:
1596
1597 .. code-block:: python
1598
1599 port = await nursery.start(http_server_on_random_open_port)
1600
1601 and this would start the server running in the background in the
1602 nursery, and then give you back the random port it selected – but
1603 not until it had finished initializing and was ready to accept
1604 requests!
1605
1606 * Added a :ref:`new abstract API for byte streams
1607 <abstract-stream-api>`, and :mod:`trio.testing` gained helpers for
1608 creating fake streams for :ref:`testing your protocol implementation
1609 <virtual-streams>` and checking that your custom stream
1610 implementation :ref:`follows the stream contract
1611 <testing-custom-streams>`.
1612
1613 * If you're currently using :mod:`trio.socket` then you should
1614 :ref:`switch to using our new high-level networking API instead
1615 <high-level-networking>`. It takes care of many tiresome details, it's
1616 fully integrated with the abstract stream API, and it provides
1617 niceties like a state-of-the-art `Happy Eyeballs implementation
1618 <https://en.wikipedia.org/wiki/Happy_Eyeballs>`__ in
1619 :func:`open_tcp_stream` and server helpers that integrate with
1620 ``nursery.start``.
1621
1622 * We've also added comprehensive support for SSL/TLS encryption,
1623 including SNI (both client and server side), STARTTLS, renegotiation
1624 during full-duplex usage (subject to OpenSSL limitations), and
1625 applying encryption to arbitrary :class:`~trio.abc.Stream`\s, which
1626 allows for interesting applications like `TLS-over-TLS
1627 <https://daniel.haxx.se/blog/2016/11/26/https-proxy-with-curl/>`__.
1628 See: :func:`trio.open_ssl_over_tcp_stream`,
1629 :func:`trio.serve_ssl_over_tcp`,
1630 :func:`trio.open_ssl_over_tcp_listeners`, and ``trio.ssl``.
1631
1632 Interesting fact: the test suite for ``trio.ssl`` has so far
1633 found bugs in CPython's ssl module, PyPy's ssl module, PyOpenSSL,
1634 and OpenSSL. (``trio.ssl`` doesn't use PyOpenSSL.) Trio's test
1635 suite is fairly thorough.
1636
1637 * You know thread-local storage? Well, Trio now has an equivalent:
1638 :ref:`task-local storage <task-local-storage>`. There's also the
1639 related, but more obscure, run-local storage; see
1640 :class:`~trio.lowlevel.RunLocal`. (`#2
1641 <https://github.com/python-trio/trio/pull/2>`__)
1642
1643 * Added a new :ref:`guide to for contributors <contributing>`.
1644
1645
1646 Breaking changes and deprecations
1647 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1648
1649 Trio has matured into a stable, production-quality foundation for
1650 async I/O in Python. While we strive to maintain stability, we may
1651 make occasional breaking changes to improve the library. Whenever
1652 possible, we provide deprecation warnings on a reasonable timeline to
1653 ease transitions. If you use Trio, we recommend `subscribing to issue
1654 #1 <https://github.com/python-trio/trio/issues/1>`__ to stay informed
1655 about changes. We also welcome feedback on how our deprecation process
1656 is working and whether it could be improved.
1657
1658 The tl;dr is: stop using ``socket.bind`` if you can, and then fix
1659 everything your test suite warns you about.
1660
1661 Upcoming breaking changes without warnings (i.e., stuff that works in
1662 0.2.0, but won't work in 0.3.0):
1663
1664 * In the next release, the ``bind`` method on Trio socket objects will
1665 become async (`#241
1666 <https://github.com/python-trio/trio/issues/241>`__). Unfortunately,
1667 there's no good way to provide a warning here. We recommend
1668 switching to the new highlevel networking APIs like
1669 :func:`serve_tcp`, which will insulate you from this change.
1670
1671 Breaking changes (i.e., stuff that could theoretically break a program
1672 that worked on 0.1.0):
1673
1674 * :mod:`trio.socket` no longer attempts to normalize or modernize
1675 socket options across different platforms. The high-level networking
1676 API now handles that, freeing :mod:`trio.socket` to focus on giving
1677 you raw, unadulterated BSD sockets.
1678
1679 * When a socket ``sendall`` call was cancelled, it used to attach some
1680 metadata to the exception reporting how much data was actually sent.
1681 It no longer does this, because in common configurations like an
1682 :class:`~trio.SSLStream` wrapped around a
1683 :class:`~trio.SocketStream` it becomes ambiguous which "level" the
1684 partial metadata applies to, leading to confusion and bugs. There is
1685 no longer any way to tell how much data was sent after a ``sendall``
1686 is cancelled.
1687
1688 * The :func:`trio.socket.getprotobyname` function is now async, like
1689 it should have been all along. I doubt anyone will ever use it, but
1690 that's no reason not to get the details right.
1691
1692 * The :mod:`trio.socket` functions ``getservbyport``,
1693 ``getservbyname``, and ``getfqdn`` have been removed, because they
1694 were obscure, buggy, and obsolete. Use
1695 :func:`~trio.socket.getaddrinfo` instead.
1696
1697 Upcoming breaking changes with warnings (i.e., stuff that in 0.2.0
1698 *will* work but will print loud complaints, and that won't work in
1699 0.3.0):
1700
1701 * For consistency with the new ``start`` method, the nursery ``spawn``
1702 method is being renamed to ``start_soon`` (`#284
1703 <https://github.com/python-trio/trio/issues/284>`__)
1704
1705 * ``trio.socket.sendall`` is deprecated; use ``trio.open_tcp_stream``
1706 and ``SocketStream.send_all`` instead (`#291
1707 <https://github.com/python-trio/trio/issues/291>`__)
1708
1709 * Trio now consistently uses ``run`` for functions that take and run
1710 an async function (like :func:`trio.run`!), and ``run_sync`` for
1711 functions that take and run a synchronous function. As part of this:
1712
1713 * ``run_in_worker_thread`` is becoming
1714 ``run_sync_in_worker_thread``
1715
1716 * We took the opportunity to refactor ``run_in_trio_thread`` and
1717 ``await_in_trio_thread`` into the new class
1718 ``trio.BlockingTrioPortal``
1719
1720 * The hazmat function ``current_call_soon_thread_and_signal_safe``
1721 is being replaced by :class:`trio.hazmat.TrioToken <trio.lowlevel.TrioToken>`
1722
1723 See `#68 <https://github.com/python-trio/trio/issues/68>`__ for
1724 details.
1725
1726 * ``trio.Queue``\'s ``join`` and ``task_done`` methods are
1727 deprecated without replacement (`#321
1728 <https://github.com/python-trio/trio/issues/321>`__)
1729
1730 * Trio 0.1.0 provided a set of built-in mechanisms for waiting for and
1731 tracking the result of individual tasks. We haven't yet found any
1732 cases where using this actually led to simpler code, though, and
1733 this feature is blocking useful improvements, so the following are
1734 being deprecated without replacement:
1735
1736 * ``nursery.zombies``
1737 * ``nursery.monitor``
1738 * ``nursery.reap``
1739 * ``nursery.reap_and_unwrap``
1740 * ``task.result``
1741 * ``task.add_monitor``
1742 * ``task.discard_monitor``
1743 * ``task.wait``
1744
1745 This also lets us move a number of lower-level features out of the
1746 main :mod:`trio` namespace and into :mod:`trio.hazmat <trio.lowlevel>`:
1747
1748 * ``trio.Task`` → :class:`trio.hazmat.Task <trio.lowlevel.Task>`
1749 * ``trio.current_task`` → :func:`trio.hazmat.current_task <trio.lowlevel.current_task>`
1750 * ``trio.Result`` → ``trio.hazmat.Result``
1751 * ``trio.Value`` → ``trio.hazmat.Value``
1752 * ``trio.Error`` → ``trio.hazmat.Error``
1753 * ``trio.UnboundedQueue`` → ``trio.hazmat.UnboundedQueue``
1754
1755 In addition, several introspection attributes are being renamed:
1756
1757 * ``nursery.children`` → ``nursery.child_tasks``
1758 * ``task.parent_task`` → use ``task.parent_nursery.parent_task`` instead
1759
1760 See `#136 <https://github.com/python-trio/trio/issues/136>`__ for
1761 more details.
1762
1763 * To consolidate introspection functionality in :mod:`trio.hazmat <trio.lowlevel>`,
1764 the following functions are moving:
1765
1766 * ``trio.current_clock`` → :func:`trio.hazmat.current_clock <trio.lowlevel.current_clock>`
1767 * ``trio.current_statistics`` →
1768 :func:`trio.hazmat.current_statistics <trio.lowlevel.current_statistics>`
1769
1770 See `#317 <https://github.com/python-trio/trio/issues/317>`__ for
1771 more details.
1772
1773 * It was decided that 0.1.0's "yield point" terminology was confusing;
1774 we now use :ref:`"checkpoint" <checkpoints>` instead. As part of
1775 this, the following functions in :mod:`trio.hazmat <trio.lowlevel>` are changing
1776 names:
1777
1778 * ``yield_briefly`` → :func:`~trio.hazmat.checkpoint <trio.lowlevel.checkpoint>`
1779 * ``yield_briefly_no_cancel`` → :func:`~trio.lowlevel.cancel_shielded_checkpoint`
1780 * ``yield_if_cancelled`` → :func:`~trio.lowlevel.checkpoint_if_cancelled`
1781 * ``yield_indefinitely`` → :func:`~trio.lowlevel.wait_task_rescheduled`
1782
1783 In addition, the following functions in :mod:`trio.testing` are
1784 changing names:
1785
1786 * ``assert_yields`` → :func:`~trio.testing.assert_checkpoints`
1787 * ``assert_no_yields`` → :func:`~trio.testing.assert_no_checkpoints`
1788
1789 See `#157 <https://github.com/python-trio/trio/issues/157>`__ for
1790 more details.
1791
1792 * ``trio.format_exception`` is deprecated; use
1793 :func:`traceback.format_exception` instead (`#347
1794 <https://github.com/python-trio/trio/pull/347>`__).
1795
1796 * ``trio.current_instruments`` is deprecated. For adding or removing
1797 instrumentation at run-time, see :func:`trio.hazmat.add_instrument <trio.lowlevel.add_instrument>`
1798 and :func:`trio.hazmat.remove_instrument <trio.lowlevel.remove_instrument>` (`#257
1799 <https://github.com/python-trio/trio/issues/257>`__)
1800
1801 Unfortunately, a limitation in PyPy3 5.8 breaks our deprecation
1802 handling for some renames. (Attempting to use the old names will give
1803 an unhelpful error instead of a helpful warning.) This does not affect
1804 CPython, or PyPy3 5.9+.
1805
1806
1807 Other changes
1808 ~~~~~~~~~~~~~
1809
1810 * ``run_sync_in_worker_thread`` now has a :ref:`robust mechanism
1811 for applying capacity limits to the number of concurrent threads
1812 <worker-thread-limiting>` (`#10
1813 <https://github.com/python-trio/trio/issues/170>`__, `#57
1814 <https://github.com/python-trio/trio/issues/57>`__, `#156
1815 <https://github.com/python-trio/trio/issues/156>`__)
1816
1817 * New support for tests to cleanly hook hostname lookup and socket
1818 operations: see :ref:`virtual-network-hooks`. In addition,
1819 ``trio.socket.SocketType`` is now an empty abstract base class, with
1820 the actual socket class made private. This shouldn't effect anyone,
1821 since the only thing you could directly use it for in the first
1822 place was ``isinstance`` checks, and those still work (`#170
1823 <https://github.com/python-trio/trio/issues/170>`__)
1824
1825 * New class :class:`StrictFIFOLock`
1826
1827 * New exception ``ResourceBusyError``
1828
1829 * The :class:`trio.hazmat.ParkingLot <trio.lowlevel.ParkingLot>` class (which is used to
1830 implement many of Trio's synchronization primitives) was rewritten
1831 to be simpler and faster (`#272
1832 <https://github.com/python-trio/trio/issues/272>`__, `#287
1833 <https://github.com/python-trio/trio/issues/287>`__)
1834
1835 * It's generally true that if you're using Trio you have to use Trio
1836 functions, if you're using asyncio you have to use asyncio
1837 functions, and so forth. (See the discussion of the "async sandwich"
1838 in the Trio tutorial for more details.) So for example, this isn't
1839 going to work:
1840
1841 .. code-block:: python
1842
1843 async def main():
1844 # asyncio here
1845 await asyncio.sleep(1)
1846
1847 # trio here
1848 trio.run(main)
1849
1850 Trio now reliably detects if you accidentally do something like
1851 this, and gives a helpful error message.
1852
1853 * Trio now also has special error messages for several other common
1854 errors, like doing ``trio.run(some_func())`` (should be
1855 ``trio.run(some_func)``).
1856
1857 * :mod:`trio.socket` now handles non-ascii domain names using the
1858 modern IDNA 2008 standard instead of the obsolete IDNA 2003 standard
1859 (`#11 <https://github.com/python-trio/trio/issues/11>`__)
1860
1861 * When an :class:`~trio.abc.Instrument` raises an unexpected error, we
1862 now route it through the :mod:`logging` module instead of printing
1863 it directly to stderr. Normally this produces exactly the same
1864 effect, but this way it's more configurable. (`#306
1865 <https://github.com/python-trio/trio/issues/306>`__)
1866
1867 * Fixed a minor race condition in IOCP thread shutdown on Windows
1868 (`#81 <https://github.com/python-trio/trio/issues/81>`__)
1869
1870 * Control-C handling on Windows now uses :func:`signal.set_wakeup_fd`
1871 and should be more reliable (`#42
1872 <https://github.com/python-trio/trio/issues/42>`__)
1873
1874 * :func:`trio.run` takes a new keyword argument
1875 ``restrict_keyboard_interrupt_to_checkpoints``
1876
1877 * New attributes allow more detailed introspection of the task tree:
1878 ``nursery.child_tasks``, ``Task.child_nurseries``,
1879 ``nursery.parent_task``, ``Task.parent_nursery``
1880
1881 * :func:`trio.testing.wait_all_tasks_blocked` now takes a
1882 ``tiebreaker=`` argument. The main use is to allow
1883 :class:`~trio.testing.MockClock`\'s auto-jump functionality to avoid
1884 interfering with direct use of
1885 :func:`~trio.testing.wait_all_tasks_blocked` in the same test.
1886
1887 * ``MultiError.catch()`` now correctly preserves ``__context__``,
1888 despite Python's best attempts to stop us (`#165
1889 <https://github.com/python-trio/trio/issues/165>`__)
1890
1891 * It is now possible to take weakrefs to :class:`Lock` and many other
1892 classes (`#331 <https://github.com/python-trio/trio/issues/331>`__)
1893
1894 * Fix ``sock.accept()`` for IPv6 sockets (`#164
1895 <https://github.com/python-trio/trio/issues/164>`__)
1896
1897 * PyCharm (and hopefully other IDEs) can now offer better completions
1898 for the :mod:`trio` and :mod:`trio.hazmat <trio.lowlevel>` modules (`#314
1899 <https://github.com/python-trio/trio/issues/314>`__)
1900
1901 * Trio now uses `yapf <https://github.com/google/yapf>`__ to
1902 standardize formatting across the source tree, so we never have to
1903 think about whitespace again.
1904
1905 * Many documentation improvements
1906
1907
1908 Trio 0.1.0 (2017-03-10)
1909 -----------------------
1910
1911 * Initial release.