Skip to content

Commit d324d9f

Browse files
committed
[trio.from_thread]
Applied `fixup_module_metadata` to `trio.from_thread` and corrected most Sphinx build warnings.
1 parent e871264 commit d324d9f

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

docs/source/history.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ Upcoming breaking changes with warnings (i.e., stuff that in 0.2.0
564564

565565
* We took the opportunity to refactor ``run_in_trio_thread`` and
566566
``await_in_trio_thread`` into the new class
567-
:class:`trio.BlockingTrioPortal`
567+
``trio.BlockingTrioPortal``
568568

569569
* The hazmat function ``current_call_soon_thread_and_signal_safe``
570570
is being replaced by :class:`trio.hazmat.TrioToken`

docs/source/reference-core.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,8 +1464,8 @@ for working with real, operating-system level,
14641464
:mod:`threading`\-module-style threads. First, if you're in Trio but
14651465
need to push some blocking I/O into a thread, there's
14661466
:func:`run_sync_in_thread`. And if you're in a thread and need
1467-
to communicate back with Trio, you can use a
1468-
`trio.from_thread`.
1467+
to communicate back with Trio, you can use
1468+
:func:`trio.from_thread.run` and :func:`trio.from_thread.run_sync`.
14691469

14701470

14711471
.. _worker-thread-limiting:
@@ -1603,9 +1603,9 @@ Putting blocking I/O into worker threads
16031603
Getting back into the Trio thread from another thread
16041604
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16051605

1606-
.. autofunction:: from_thread.run
1606+
.. autofunction:: trio.from_thread.run
16071607

1608-
.. autofunction:: from_thread.run_sync
1608+
.. autofunction:: trio.from_thread.run_sync
16091609

16101610
This will probably be clearer with an example. Here we demonstrate how
16111611
to spawn a child thread, and then use a :ref:`memory channel

docs/source/reference-hazmat.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ These transitions are accomplished using two function decorators:
339339
function).
340340

341341
An example of where you'd use this is in implementing something
342-
like :meth:`trio.from_thread.run`, which uses
342+
like :func:`trio.from_thread.run`, which uses
343343
:meth:`TrioToken.run_sync_soon` to get into the Trio
344344
thread. :meth:`~TrioToken.run_sync_soon` callbacks are run with
345345
:exc:`KeyboardInterrupt` protection enabled, and
346-
:meth:`~trio.from_thread.run` takes advantage of this to safely set up
346+
:func:`trio.from_thread.run` takes advantage of this to safely set up
347347
the machinery for sending a response back to the original thread, but
348348
then uses :func:`disable_ki_protection` when entering the
349349
user-provided function.

trio/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
_BlockingTrioPortal,
120120
"0.12.0",
121121
issue=810,
122-
instead=("trio.from_thread.run(), trio.from_thread.run_sync()")
122+
instead=from_thread,
123123
),
124124
}
125125

@@ -134,6 +134,7 @@
134134
fixup_module_metadata(hazmat.__name__, hazmat.__dict__)
135135
fixup_module_metadata(socket.__name__, socket.__dict__)
136136
fixup_module_metadata(abc.__name__, abc.__dict__)
137+
fixup_module_metadata(from_thread.__name__, from_thread.__dict__)
137138
fixup_module_metadata(__name__ + ".ssl", _deprecated_ssl_reexports.__dict__)
138139
fixup_module_metadata(
139140
__name__ + ".subprocess", _deprecated_subprocess_reexports.__dict__

trio/_threads.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def run(afn, *args, trio_token=None):
369369
already completed.
370370
Cancelled: if the corresponding call to :func:`trio.run` completes
371371
while ``afn(*args)`` is running, then ``afn`` is likely to raise
372-
:class:`Cancelled`, and this will propagate out into
372+
:exc:`trio.Cancelled`, and this will propagate out into
373373
RuntimeError: if you try calling this from inside the Trio thread,
374374
which would otherwise cause a deadlock.
375375
AttributeError: if run()'s thread local storage does not have a token.
@@ -415,7 +415,7 @@ def run_sync(fn, *args, trio_token=None):
415415
already completed.
416416
Cancelled: if the corresponding call to `trio.run` completes
417417
while ``afn(*args)`` is running, then ``afn`` is likely to raise
418-
:class:`Cancelled`, and this will propagate out into
418+
:exc:`trio.Cancelled`, and this will propagate out into
419419
RuntimeError: if you try calling this from inside the Trio thread,
420420
which would otherwise cause a deadlock.
421421
AttributeError: if run()'s thread local storage does not have a token.

0 commit comments

Comments
 (0)