Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put BlockingTrioPortal back where it's supposed to be. #1168

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions docs/source/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ Features
`~trio.abc.ReceiveStream.receive_some`; you can ``await
stream.receive_some()`` with no arguments, and the stream will
automatically pick a reasonable size for you. (`#959 <https://github.com/python-trio/trio/issues/959>`__)
- Threading interfaces have been reworked:
``run_sync_in_worker_thread`` is now `trio.to_thread.run_sync`, and
instead of ``BlockingTrioPortal``, use `trio.from_thread.run` and
`trio.from_thread.run_sync`. What's neat about this is that these
cooperate, so if you're in a thread created by `to_thread.run_sync`,
it remembers which Trio created it, and you can call
``trio.from_thread.*`` directly without having to pass around a
``BlockingTrioPortal`` object everywhere. (`#810 <https://github.com/python-trio/trio/issues/810>`__)
- We cleaned up the distinction between the "abstract channel interface"
and the "memory channel" concrete implementation.
`trio.abc.SendChannel` and `trio.abc.ReceiveChannel` have been slimmed
Expand Down Expand Up @@ -86,11 +94,15 @@ Deprecations and Removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- The ``clear`` method on `trio.Event` has been deprecated. (`#637 <https://github.com/python-trio/trio/issues/637>`__)
- ``run_sync_in_worker_thread`` has become `trio.to_thread.run_sync`, in
order to make it shorter, and more consistent with the new
``trio.from_thread``. And ``current_default_worker_thread_limiter`` is
now `trio.to_thread.current_default_thread_limiter`. (Of course the
old names still work with a deprecation warning, for now.) (`#810 <https://github.com/python-trio/trio/issues/810>`__)
- ``BlockingTrioPortal`` has been deprecated in favor of the new
`trio.from_thread`. (`#810
<https://github.com/python-trio/trio/issues/810>`__)
- ``run_sync_in_worker_thread`` is deprecated in favor of
`trio.to_thread.run_sync`. (`#810
<https://github.com/python-trio/trio/issues/810>`__)
- ``current_default_worker_thread_limiter`` is deprecated in favor of
`trio.to_thread.current_default_thread_limiter`. (`#810
<https://github.com/python-trio/trio/issues/810>`__)
- Give up on trying to have different low-level waiting APIs on Unix and
Windows. All platforms now have `trio.hazmat.wait_readable`,
`trio.hazmat.wait_writable`, and `trio.hazmat.notify_closing`. The old
Expand Down
3 changes: 3 additions & 0 deletions newsfragments/1167.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
In v0.12.0, we accidentally moved ``BlockingTrioPortal`` from ``trio``
to ``trio.hazmat``. It's now been restored to its proper position.
(It's still deprecated though, and will issue a warning if you use it.)
14 changes: 7 additions & 7 deletions trio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@
"0.12.0",
issue=810,
),
"BlockingTrioPortal":
_deprecate.DeprecatedAttribute(
_BlockingTrioPortal,
"0.12.0",
issue=810,
instead=from_thread,
),
}

_deprecate.enable_attribute_deprecations(hazmat.__name__)
Expand Down Expand Up @@ -143,13 +150,6 @@
"0.12.0",
issue=878,
),
"BlockingTrioPortal":
_deprecate.DeprecatedAttribute(
_BlockingTrioPortal,
"0.12.0",
issue=810,
instead=from_thread,
),
}

# Having the public path in .__module__ attributes is important for:
Expand Down
6 changes: 6 additions & 0 deletions trio/tests/test_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,3 +560,9 @@ def worker_thread(token):

t = await to_thread_run_sync(worker_thread, token)
assert t == threading.current_thread()


def test_BlockingTrioPortal_deprecated_export(recwarn):
import trio
btp = trio.BlockingTrioPortal
assert btp is BlockingTrioPortal