aboutsummaryrefslogtreecommitdiffstats
path: root/examples/async/eratosthenes/doc/eratosthenes.rst
diff options
context:
space:
mode:
Diffstat (limited to 'examples/async/eratosthenes/doc/eratosthenes.rst')
-rw-r--r--examples/async/eratosthenes/doc/eratosthenes.rst29
1 files changed, 20 insertions, 9 deletions
diff --git a/examples/async/eratosthenes/doc/eratosthenes.rst b/examples/async/eratosthenes/doc/eratosthenes.rst
index fdb095a91..494a94df3 100644
--- a/examples/async/eratosthenes/doc/eratosthenes.rst
+++ b/examples/async/eratosthenes/doc/eratosthenes.rst
@@ -6,9 +6,18 @@ The Python language provides keywords for asynchronous operations, i.e.,
event loop (see `PEP 492 <https://peps.python.org/pep-0492/>`_). It is up to
packages to implement an event loop, support for these keywords, and more.
-One such package is `trio`. Since both an async package and Qt itself work with
-event loops, special care must be taken to ensure that both event loops work
-with each other. trio offers a dedicated `low-level API
+The best-known package for this is `asyncio`. Since both an async package and
+Qt itself work with event loops, special care must be taken to ensure that both
+event loops work with each other. asyncio offers a function `stop` that allows
+stopping an event loop without closing it. If it is called while a loop is
+running through `run_forever`, the loop will run the current batch of callbacks
+and then exit. New callbacks wil be scheduled the next time `run_forever` is
+called.
+
+This approach is highly experimental and does not represent the state of the
+art of integrating Qt with asyncio. Instead it should rather be regarded more
+as a proof of concept to contrast asyncio with other async packages such as
+`trio`, which offers a dedicated `low-level API
<https://trio.readthedocs.io/en/stable/reference-lowlevel.html>`_ for more
complicated use cases such as this. Specifically, there exists a function
`start_guest_run` that enables running the Trio event loop as a "guest" inside
@@ -34,9 +43,11 @@ Both examples feature:
1. A window class.
2. An `AsyncHelper` class containing `start_guest_run` plus helpers and
- callbacks necessary for its invocation. The entry point for the Trio guest
- run is provided as an argument from outside, which can be any async function.
-
-While `eratosthenes` offloads the asynchronous logic that will run in trio's
-event loop into a separate class, `minimal` demonstrates that async functions
-can be integrated into any class, including subclasses of Qt classes.
+ callbacks necessary for its invocation. The entry point for the Trio/asyncio
+ guest run is provided as an argument from outside, which can be any async
+ function.
+
+While `eratosthenes` offloads the asynchronous logic that will run in
+trio's/asyncio's event loop into a separate class, `minimal` demonstrates that
+async functions can be integrated into any class, including subclasses of Qt
+classes.