Skip to content

Commit 1be4008

Browse files
author
Andrew J Westlake
committed
Reviewed the docs changes
1 parent b49901f commit 1be4008

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ where
193193

194194
/// Attempt to initialize the Python and Rust event loops
195195
///
196-
/// - Must be called before any other pyo3-asyncio functions
197-
/// - Calling `try_init` twice returns `Ok(())` and does nothing
198-
/// > In future versions this may return an `Err`
196+
/// - Must be called before any other pyo3-asyncio functions.
197+
/// - Calling `try_init` a second time returns `Ok(())` and does nothing.
198+
/// > In future versions this may return an `Err`.
199199
pub fn try_init(py: Python) -> PyResult<()> {
200200
EVENT_LOOP.get_or_try_init(|| -> PyResult<PyObject> {
201201
let asyncio = py.import("asyncio")?;

src/tokio.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ fn start_current_thread() {
7777
}
7878

7979
/// Initialize the Tokio Runtime with current-thread scheduler
80+
///
81+
/// # Panics
82+
/// This function will panic if called a second time. See [`init_current_thread_once`] if you want
83+
/// to avoid this panic.
8084
pub fn init_current_thread() {
8185
init(current_thread());
8286
start_current_thread();
@@ -95,22 +99,26 @@ fn multi_thread() -> Runtime {
9599
}
96100

97101
/// Initialize the Tokio Runtime with the multi-thread scheduler
102+
///
103+
/// # Panics
104+
/// This function will panic if called a second time. See [`init_multi_thread_once`] if you want to
105+
/// avoid this panic.
98106
pub fn init_multi_thread() {
99107
init(multi_thread());
100108
}
101109

102110
/// Ensure that the Tokio Runtime is initialized
103111
///
104112
/// If the runtime has not been initialized already, the multi-thread scheduler
105-
/// is used. Otherwise this function is a no-op.
113+
/// is used. Calling this function a second time is a no-op.
106114
pub fn init_multi_thread_once() {
107115
TOKIO_RUNTIME.get_or_init(|| multi_thread());
108116
}
109117

110118
/// Ensure that the Tokio Runtime is initialized
111119
///
112120
/// If the runtime has not been initialized already, the current-thread
113-
/// scheduler is used. Otherwise this function is a no-op
121+
/// scheduler is used. Calling this function a second time is a no-op.
114122
pub fn init_current_thread_once() {
115123
let mut initialized = false;
116124
TOKIO_RUNTIME.get_or_init(|| {

0 commit comments

Comments
 (0)