Skip to content

Commit 2f6b054

Browse files
author
Andrew J Westlake
committed
Fixed some documentation
1 parent bfc8d68 commit 2f6b054

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pyo3 = { git = "https://github.com/PyO3/pyo3" }
2424

2525
## Quickstart
2626

27-
Here we initialize the runtime, import Python's `asyncio` library and run the given future to completion using Python's default `EventLoop` and Tokio. Inside the future, we convert `asyncio` sleep into a Rust future and await it.
27+
Here we initialize the runtime, import Python's `asyncio` library and run the given future to completion using Python's default `EventLoop` and `async-std`. Inside the future, we convert `asyncio` sleep into a Rust future and await it.
2828

2929
More details on the usage of this library can be found in the [API docs](https://awestlake87.github.io/pyo3-asyncio/master/doc).
3030

src/async_std.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
//!
1818
//! `pytests/test_example.rs`
1919
//! ```no_run
20-
//!
2120
//! fn main() {
2221
//!
2322
//! }
@@ -96,7 +95,7 @@ use crate::{get_event_loop, CALL_SOON, CREATE_FUTURE, EXPECT_INIT};
9695
/// The event loop runs until the given future is complete.
9796
///
9897
/// After this function returns, the event loop can be resumed with either [`run_until_complete`] or
99-
/// [`run_forever`]
98+
/// [`crate::run_forever`]
10099
///
101100
/// # Arguments
102101
/// * `py` - The current PyO3 GIL guard
@@ -265,6 +264,7 @@ where
265264
Ok(future_rx)
266265
}
267266

267+
/// <span class="module-item stab portability" style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"><code>testing</code></span> Testing Utilities for the async-std runtime.
268268
#[cfg(feature = "testing")]
269269
pub mod testing {
270270
use async_std::task;

src/lib.rs

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
//! be run on the same event loop.
1919
//!
2020
//! It's not immediately clear that this would provide worthwhile performance wins either, so in the
21-
//! interest of keeping things simple, this crate runs both event loops independently and handles
22-
//! the communication between them.
21+
//! interest of keeping things simple, this crate creates and manages the Python event loop and
22+
//! handles the communication between separate Rust event loops.
2323
//!
2424
//! ## Python's Event Loop
2525
//!
@@ -30,9 +30,7 @@
3030
//!
3131
//! ## Rust's Event Loop
3232
//!
33-
//! Currently only the Tokio runtime is supported by this crate. Tokio makes it easy to construct
34-
//! and maintain a runtime that runs on background threads only and it provides a single threaded
35-
//! scheduler to make it easier to work around Python's GIL.
33+
//! Currently only the async-std and Tokio runtimes are supported by this crate.
3634
//!
3735
//! > _In the future, more runtimes may be supported for Rust._
3836
//!
@@ -42,6 +40,32 @@
4240
//! <span
4341
//! class="module-item stab portability"
4442
//! style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"
43+
//! ><code>async-std-runtime</code></span>
44+
//! are only available when the `async-std-runtime` Cargo feature is enabled:
45+
//!
46+
//! ```toml
47+
//! [dependencies.pyo3-asyncio]
48+
//! version = "0.13.0"
49+
//! features = ["async-std-runtime"]
50+
//! ```
51+
//!
52+
//! Items marked with
53+
//! <span
54+
//! class="module-item stab portability"
55+
//! style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"
56+
//! ><code>tokio-runtime</code></span>
57+
//! are only available when the `tokio-runtime` Cargo feature is enabled:
58+
//!
59+
//! ```toml
60+
//! [dependencies.pyo3-asyncio]
61+
//! version = "0.13.0"
62+
//! features = ["tokio-runtime"]
63+
//! ```
64+
//!
65+
//! Items marked with
66+
//! <span
67+
//! class="module-item stab portability"
68+
//! style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"
4569
//! ><code>testing</code></span>
4670
//! are only available when the `testing` Cargo feature is enabled:
4771
//!
@@ -56,10 +80,12 @@
5680
#[doc(inline)]
5781
pub mod testing;
5882

83+
/// <span class="module-item stab portability" style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"><code>async-std-runtime</code></span> PyO3 Asyncio functions specific to the async-std runtime
5984
#[cfg(feature = "async-std")]
6085
#[doc(inline)]
6186
pub mod async_std;
6287

88+
/// <span class="module-item stab portability" style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"><code>tokio-runtime</code></span> PyO3 Asyncio functions specific to the tokio runtime
6389
#[cfg(feature = "tokio-runtime")]
6490
#[doc(inline)]
6591
pub mod tokio;
@@ -172,11 +198,11 @@ pub fn get_event_loop(py: Python) -> &PyAny {
172198

173199
/// Run the event loop forever
174200
///
175-
/// This can be called instead of [`run_until_complete`] to run the event loop
201+
/// This can be called instead of `run_until_complete` to run the event loop
176202
/// until `stop` is called rather than driving a future to completion.
177203
///
178-
/// After this function returns, the event loop can be resumed with either [`run_until_complete`] or
179-
/// [`run_forever`]
204+
/// After this function returns, the event loop can be resumed with either `run_until_complete` or
205+
/// [`crate::run_forever`]
180206
///
181207
/// # Arguments
182208
/// * `py` - The current PyO3 GIL guard

src/tokio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
//!
1818
//! `pytests/test_example.rs`
1919
//! ```no_run
20-
//!
2120
//! fn main() {
2221
//!
2322
//! }
@@ -129,7 +128,7 @@ use crate::{get_event_loop, CALL_SOON, CREATE_FUTURE, EXPECT_INIT};
129128
/// The event loop runs until the given future is complete.
130129
///
131130
/// After this function returns, the event loop can be resumed with either [`run_until_complete`] or
132-
/// [`run_forever`]
131+
/// [`crate::run_forever`]
133132
///
134133
/// # Arguments
135134
/// * `py` - The current PyO3 GIL guard
@@ -315,6 +314,7 @@ where
315314
Ok(future_rx)
316315
}
317316

317+
/// <span class="module-item stab portability" style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"><code>testing</code></span> Testing Utilities for the Tokio runtime.
318318
#[cfg(feature = "testing")]
319319
pub mod testing {
320320
use ::tokio::runtime::Runtime;

0 commit comments

Comments
 (0)